List
List credit grants
client.V1.CreditGrants.List(ctx, params) (*CursorPage[IDstringBalanceV1CreditGrantListResponseBalanceCustomFieldsmapCustomerIDstringDeductionsarrayEffectiveAtTimeExpiresAtTimeGrantAmountV1CreditGrantListResponseGrantAmountNamestringPaidAmountV1CreditGrantListResponsePaidAmountPendingDeductionsarrayPriorityfloat64CreditGrantTypestringInvoiceIDstringProductsarrayReasonstringUniquenessKeystringV1CreditGrantListResponse], error)
post/v1/credits/listGrants
List credit grants. This list does not included voided grants.
Parameters
paramsLimitfieldNextPagefieldCreditGrantIDsfieldCreditTypeIDsfieldCustomerIDsfieldEffectiveBeforefieldNotExpiringBeforefieldV1CreditGrantListParams
Returns
V1CreditGrantListResponsestruct
package main
import (
"context"
"fmt"
"time"
"github.com/Metronome-Industries/metronome-go"
"github.com/Metronome-Industries/metronome-go/option"
)
func main() {
client := metronome.NewClient(
option.WithBearerToken("My Bearer Token"),
)
page, err := client.V1.CreditGrants.List(context.TODO(), metronome.V1CreditGrantListParams{
CreditTypeIDs: metronome.F([]string{"2714e483-4ff1-48e4-9e25-ac732e8f24f2"}),
CustomerIDs: metronome.F([]string{"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc", "0e5b8609-d901-4992-b394-c3c2e3f37b1c"}),
EffectiveBefore: metronome.F(time.Now()),
NotExpiringBefore: metronome.F(time.Now()),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
200 Example
{
"data": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"balance": {
"effective_at": "2019-12-27T18:11:19.117Z",
"excluding_pending": 0,
"including_pending": 0
},
"custom_fields": {
"foo": "string"
},
"customer_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"deductions": [
{
"amount": 0,
"created_by": "created_by",
"credit_grant_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"effective_at": "2019-12-27T18:11:19.117Z",
"reason": "Automated invoice deduction",
"running_balance": 0,
"invoice_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
],
"effective_at": "2019-12-27T18:11:19.117Z",
"expires_at": "2019-12-27T18:11:19.117Z",
"grant_amount": {
"amount": 0,
"credit_type": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"name": "name"
}
},
"name": "name",
"paid_amount": {
"amount": 0,
"credit_type": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"name": "name"
}
},
"pending_deductions": [
{
"amount": 0,
"created_by": "created_by",
"credit_grant_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"effective_at": "2019-12-27T18:11:19.117Z",
"reason": "Automated invoice deduction",
"running_balance": 0,
"invoice_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
],
"priority": 0,
"credit_grant_type": "credit_grant_type",
"invoice_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"products": [
{
"id": "id",
"name": "name"
}
],
"reason": "reason",
"uniqueness_key": "x"
}
],
"next_page": "next_page"
}