-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookkeepingentry.go
130 lines (115 loc) · 4.6 KB
/
bookkeepingentry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// File generated from our OpenAPI spec by Stainless.
package acme
import (
"context"
"fmt"
"net/http"
"net/url"
"time"
"github.com/acme/acme-go/internal/apijson"
"github.com/acme/acme-go/internal/apiquery"
"github.com/acme/acme-go/internal/param"
"github.com/acme/acme-go/internal/requestconfig"
"github.com/acme/acme-go/internal/shared"
"github.com/acme/acme-go/option"
)
// BookkeepingEntryService contains methods and other services that help with
// interacting with the acme API. Note, unlike clients, this service does not
// read variables from the environment automatically. You should not instantiate
// this service directly, and instead use the [NewBookkeepingEntryService] method
// instead.
type BookkeepingEntryService struct {
Options []option.RequestOption
}
// NewBookkeepingEntryService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewBookkeepingEntryService(opts ...option.RequestOption) (r *BookkeepingEntryService) {
r = &BookkeepingEntryService{}
r.Options = opts
return
}
// Retrieve a Bookkeeping Entry
func (r *BookkeepingEntryService) Get(ctx context.Context, bookkeepingEntryID string, opts ...option.RequestOption) (res *BookkeepingEntry, err error) {
opts = append(r.Options[:], opts...)
path := fmt.Sprintf("bookkeeping_entries/%s", bookkeepingEntryID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// List Bookkeeping Entries
func (r *BookkeepingEntryService) List(ctx context.Context, query BookkeepingEntryListParams, opts ...option.RequestOption) (res *shared.Page[BookkeepingEntry], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "bookkeeping_entries"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// List Bookkeeping Entries
func (r *BookkeepingEntryService) ListAutoPaging(ctx context.Context, query BookkeepingEntryListParams, opts ...option.RequestOption) *shared.PageAutoPager[BookkeepingEntry] {
return shared.NewPageAutoPager(r.List(ctx, query, opts...))
}
// Entries are T-account entries recording debits and credits. Your compliance
// setup might require annotating money movements using this API. Learn more in our
// [guide to Bookkeeping](https://acme.com/documentation/bookkeeping#bookkeeping).
type BookkeepingEntry struct {
// The entry identifier.
ID string `json:"id,required"`
// The identifier for the Account the Entry belongs to.
AccountID string `json:"account_id,required"`
// The Entry amount in the minor unit of its currency. For dollars, for example,
// this is cents.
Amount int64 `json:"amount,required"`
// When the entry set was created.
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
// The identifier for the Account the Entry belongs to.
EntrySetID string `json:"entry_set_id,required"`
// A constant representing the object's type. For this resource it will always be
// `bookkeeping_entry`.
Type BookkeepingEntryType `json:"type,required"`
JSON bookkeepingEntryJSON `json:"-"`
}
// bookkeepingEntryJSON contains the JSON metadata for the struct
// [BookkeepingEntry]
type bookkeepingEntryJSON struct {
ID apijson.Field
AccountID apijson.Field
Amount apijson.Field
CreatedAt apijson.Field
EntrySetID apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *BookkeepingEntry) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
// A constant representing the object's type. For this resource it will always be
// `bookkeeping_entry`.
type BookkeepingEntryType string
const (
BookkeepingEntryTypeBookkeepingEntry BookkeepingEntryType = "bookkeeping_entry"
)
type BookkeepingEntryListParams struct {
// Return the page of entries after this one.
Cursor param.Field[string] `query:"cursor"`
// Limit the size of the list that is returned. The default (and maximum) is 100
// objects.
Limit param.Field[int64] `query:"limit"`
}
// URLQuery serializes [BookkeepingEntryListParams]'s query parameters as
// `url.Values`.
func (r BookkeepingEntryListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatDots,
})
}