Categorygithub.com/generalworksinc/sumaregi-go
modulepackage
0.0.0-20241231095826-ef57b40aa04f
Repository: https://github.com/generalworksinc/sumaregi-go.git
Documentation: pkg.go.dev

# README

Go API client for sumaregi

sumaregi API のクライアントライブラリ

Usage

package main

import (
	"context"
	"log"
	"time"

	"github.com/Tsubasa-2005/sumaregi-go"
)

func main() {
	development := false
	envVari, err := sumaregi.LoadEnv(development)
	if err != nil {
		log.Fatalf("Failed to load environment variables: %v", err)
	}
	config := sumaregi.NewConfig(envVari)
	scopes := []string{sumaregi.TransactionsRead}
	client, err := sumaregi.NewClient(config, scopes, envVari)
	if err != nil {
		log.Fatalf("Failed to create client: %v", err)
	}

	ctx := context.Background()
	now := time.Now()
	transactionDateTimeFrom := now.AddDate(0, 0, -2)
	transactionDateTimeTo := now.AddDate(0, 0, -1)

	transactions, err := client.GetTransactions(ctx, sumaregi.GetTransactionsOpts{
		TransactionDateTimeFrom: sumaregi.FormatToISO8601(transactionDateTimeFrom),
		TransactionDateTimeTo:   sumaregi.FormatToISO8601(transactionDateTimeTo),
		Limit:                   2,
	})
	if err != nil {
		log.Fatalf("Failed to get products: %v", err)
	}

	sumaregi.PrintResponse(*transactions)
	for _, transaction := range *transactions {
		transactionDetail, err := client.GetTransactionDetail(ctx, sumaregi.GetTransactionDetailOpts{}, transaction.TransactionHeadID)
		if err != nil {
			log.Printf("Failed to get transaction details for ID %s: %v", transaction.TransactionHeadID, err)
			break
		}
		sumaregi.PrintResponse(*transactionDetail)
	}
}


References

APIs

取引

  • GET /{契約ID}/pos/transactions 取引一覧取得
  • GET /{契約ID}/pos/transactions/{id} 取引取得

# Packages

sumaregi.PrintResponse(*transactions) for _, transaction := range *transactions { transactionDetail, err := client.GetTransactionDetail(ctx, sumaregi.GetTransactionDetailOpts{}, transaction.TransactionHeadID) if err != nil { log.Printf("Failed to get transaction details for ID %s: %v", transaction.TransactionHeadID, err) break } sumaregi.PrintResponse(*transactionDetail) } }.

# Functions

JoinScopes joins slices of scope strings into a single string separated by spaces.
LoadEnv loads environment variables from .env file.
No description provided by the author
No description provided by the author
ジェネリックな表示関数.
単一の構造体の中身を表示する関数.
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
適用セール値引き額。.
適用セール値。.
セール値引き按分。.
セール区分。.
セールID。.
セール名称。.
セール値。.
値引割引計算対象。.
部門ID:数字9桁以内。.
部門名:85文字以内。.
カラー:85文字以内。.
原価:少数5桁まで。.
原価計:少数5桁まで。.
会員ID:10桁以内。.
customers.
sumaregi scopes.
クーポン値引き按分。.
ポイント値引き按分。.
小計値引き按分。.
識別番号:20桁以内。.
グループコード:関連商品として紐付け。.
在庫引当区分。.
No description provided by the author
No description provided by the author
No description provided by the author
losses.
sumaregi scopes.
修正税率。.
order-shipment-orders.
sumaregi scopes.
order-shipment-stocks.
order-shipment-stores.
sumaregi scopes.
orders.
sumaregi scopes.
親取引明細ID:紐付く親の取引明細ID。ない場合はNULL。.
ポイント対象:0:対象, 1:対象外。.
商品単価:数値型。.
レシート印字商品名:64文字以内。.
商品バンドルグループID。.
商品バンドル値引按分。.
商品コード:最大64桁。.
商品区分:0:通常, 4:バンドル(親), 7:バンドル商品(子), ...
商品ID:数字15桁以内。.
商品名:85文字以内。.
products.
商品毎の社員割引率。.
sumaregi scopes.
数量:数値型。.
軽減税率ID。.
軽減税率用会員商品単価。.
軽減税率名。.
軽減税率用商品単価。.
軽減税率。.
売上区分:0:売上対象, 1:売上対象外。.
販売単価。.
サイズ:85文字以内。.
社員販売割引区分。.
社員値引き按分。.
社員販売割引率。.
社員ランクコード。.
社員ランク名。.
staffs.
sumaregi scopes.
標準税率。.
sumaregi scopes.
stock.
stock-takings.
sumaregi scopes.
店舗ID:店舗毎に付与するID。.
stores.
sumaregi scopes.
締め日:[YYYY-MM-DD].
suppliers.
sumaregi scopes.
税区分:0:税込, 1:税抜, 2:非課税。.
外税按分。.
免税額:数値型。.
免税対象額:数値型。.
免税区分。.
内税按分。.
適用税率。.
端末ID:店舗の端末毎に付与するID。.
端末取引ID:端末で設定された取引ID。.
attendances.
daily-reports.
sumaregi timecard scopes.
holidays.
sumaregi timecard scopes.
salaries.
sumaregi timecard scopes.
settings.
shifts.
sumaregi timecard scopes.
staffs.
stores.
取引日時。[YYYY-MM-DDThh:mm:ssTZD].
取引明細区分:1:通常, 2:返品, 3:部門売り。.
取引明細ID:数値型。.
取引区分:1:通常, 2:入金, 3:出金, ...
取引ID:数値型。.
transactions.
sumaregi scopes.
transfers.
sumaregi scopes.
単品値引き/割引区分。.
値引き後計:値引き前計-単品値引き。.
単品値引:値引き金額。.
単品割引率:単位:%。.
単品値引き計:値引き×数量。.
値引き前計:販売価格×数量。.
更新日時:[YYYY-MM-DDThh:mm:ssTZD].
menues.
sumaregi waiter scopes.
orders.
sumaregi waiter scopes.
reservations.
sumaregi waiter scopes.
staff-calls.
sumaregi waiter scopes.
stores.

# Structs

No description provided by the author
No description provided by the author
Config is a setting for Smaregi APIs.
No description provided by the author
No description provided by the author
GetCategoryOpts represents options for GetCategory.
GetCategoryResponse represents the response of GetCategory.
No description provided by the author
No description provided by the author
No description provided by the author
GetProductsOpts は、商品データを取得する際のクエリパラメータを表します。.
No description provided by the author
No description provided by the author
No description provided by the author
GetTransactionDetailOpts represents options for GetTransactionDetail.
GetTransactionsOpts represents options for GetTransactions.
PostProductsParams 、APIで商品を作成または更新するためのパラメータを表します。.
No description provided by the author
PostTransactionCSVOpts represents the request structure for fetching transaction details.
No description provided by the author

# Interfaces

Logger generic interface for logger.

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetTransactionDetailResponse represents a response from GetTransactionDetail.
GetTransactionsResponse represents a response from GetTransactions.
No description provided by the author