定制 usegenuka/genuka-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

usegenuka/genuka-php

最新稳定版本:v1.0.0

Composer 安装命令:

composer require usegenuka/genuka-php

包简介

PHP SDK for Genuka e-commerce platform API

README 文档

README

Tests PHP Version License: MIT

PHP SDK for integrating with the Genuka e-commerce platform API.

Requirements

  • PHP >= 8.1
  • Composer

Installation

composer require usegenuka/genuka-php

Quick Start

<?php

require_once 'vendor/autoload.php';

use Genuka\Genuka;

// Initialize with your domain
$genuka = Genuka::initialize([
    'domain' => 'maboutique.genuka.com'
]);

// List products
$products = $genuka->products()->list([
    'page' => 1,
    'limit' => 10
]);

// Get a specific product
$product = $genuka->products()->retrieve(['id' => 'product-id']);

Configuration Options

Option Type Default Description
domain string - Your shop domain (e.g., maboutique.genuka.com)
token string - Authentication token
lang string en Language for API responses
timezone string Africa/Douala Timezone for date/time handling
apiBaseUrl string https://api.genuka.com Custom API base URL
version string 2023-11 API version
adminMode bool false Enable admin mode
companyId string - Company ID (auto-resolved from domain)
shopId string - Shop ID (auto-resolved from domain)

Full Configuration Example

$genuka = Genuka::initialize([
    'domain' => 'maboutique.genuka.com',
    'token' => 'your-auth-token',
    'lang' => 'fr',
    'timezone' => 'Africa/Douala',
]);

Usage

Company

$company = $genuka->company()->retrieve();

Shops

// List all shops
$shops = $genuka->shops()->list();

// Get a specific shop
$shop = $genuka->shops()->retrieve(['id' => 'shop-id']);

Products

// Count products
$count = $genuka->products()->count();

// List products with filters
$products = $genuka->products()->list([
    'page' => 1,
    'limit' => 20,
    'filter' => ['collections' => 'collection-id'],
    'sort' => ['-created_at'],
]);

// Get a product by ID
$product = $genuka->products()->retrieve(['id' => 'product-id']);

// Get a product by handle
$product = $genuka->products()->retrieve(['handle' => 'product-handle']);

Collections

$collections = $genuka->collections()->list();
$collection = $genuka->collections()->retrieve(['id' => 'collection-id']);

Customers

// Login
$result = $genuka->customers()->login([
    'email' => 'customer@example.com',
    'password' => 'password'
]);
$genuka->setToken($result['token']);

// Get current customer
$customer = $genuka->customers()->me();

// Register a new customer
$customer = $genuka->customers()->register([
    'first_name' => 'Jean',
    'last_name' => 'Dupont',
    'email' => 'jean@example.com',
    'password' => 'password',
    'password_confirmation' => 'password',
]);

// Forgot password
$genuka->customers()->forgotPassword('customer@example.com');

Orders

// List customer orders (requires authentication)
$orders = $genuka->orders()->list();

// Create an order
$order = $genuka->orders()->create([
    'customer' => [
        'first_name' => 'Jean',
        'last_name' => 'Dupont',
        'phone' => '+237699000000',
        'email' => 'jean@example.com',
    ],
    'shipping' => [
        'mode' => 'delivery',
        'amount' => 1000,
        'address' => [
            'first_name' => 'Jean',
            'last_name' => 'Dupont',
            'phone' => '+237699000000',
            'line1' => 'Rue de la Joie',
            'city' => 'Douala',
            'country' => 'Cameroon',
        ],
    ],
    'billing' => [
        'method' => 'cash',
        'address' => [
            'first_name' => 'Jean',
            'last_name' => 'Dupont',
            'phone' => '+237699000000',
            'line1' => 'Rue de la Joie',
            'city' => 'Douala',
            'country' => 'Cameroon',
        ],
    ],
    'products' => [
        [
            'title' => 'Mon produit',
            'price' => 5000,
            'quantity' => 2,
        ],
    ],
]);

Cart (Local)

// Add item to cart
$genuka->cart()->add([
    'product_id' => 'product-id',
    'variant_id' => 'variant-id',
    'quantity' => 2,
    'price' => 5000,
]);

// Get cart contents
$items = $genuka->cart()->retrieve();

// Update item quantity
$genuka->cart()->update('variant-id', ['quantity' => 3]);

// Remove item
$genuka->cart()->remove('variant-id');

// Get cart total
$total = $genuka->cart()->total();

// Clear cart
$genuka->cart()->clear();

Pages & Blog

// Pages
$pages = $genuka->pages()->list();
$page = $genuka->pages()->retrieve(['id' => 'page-id']);

// Blogs
$blogs = $genuka->blogs()->list();

// Articles
$articles = $genuka->articles()->list();
$article = $genuka->articles()->retrieve(['id' => 'article-id']);

Other Services

// Addresses
$addresses = $genuka->addresses()->list();

// Payment Methods
$paymentMethods = $genuka->paymentMethods()->list();

// Shipping Methods
$shippings = $genuka->shippings()->list();

Available Services

Service Methods
company() retrieve()
shops() list(), retrieve(), count()
products() list(), retrieve(), count(), create(), update(), delete()
collections() list(), retrieve(), count()
customers() login(), register(), me(), updateProfile(), forgotPassword(), resetPassword()
orders() list(), retrieve(), count(), create()
cart() add(), retrieve(), update(), remove(), clear(), total(), count()
pages() list(), retrieve(), count()
blogs() list(), retrieve(), count()
articles() list(), retrieve(), count()
addresses() list(), retrieve(), create(), update(), delete()
paymentMethods() list(), retrieve()
shippings() list(), retrieve()

Error Handling

use Genuka\Exceptions\GenukaException;

try {
    $product = $genuka->products()->retrieve(['id' => 'invalid-id']);
} catch (GenukaException $e) {
    echo "Error: " . $e->getMessage();
    echo "Code: " . $e->getCode();
}

Contributing

Contributions are welcome! Please contact us via WhatsApp (+237 6 95 76 25 95) or email at it@genuka.com.

License

MIT License. See LICENSE for details.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-01