Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nil values not ommitted in sdk api calls #38

Open
aliotta opened this issue Oct 28, 2024 · 0 comments
Open

Nil values not ommitted in sdk api calls #38

aliotta opened this issue Oct 28, 2024 · 0 comments

Comments

@aliotta
Copy link

aliotta commented Oct 28, 2024

I've noticed that a bunch of values returned from the sdk are structs with all values set to go nil values. e.g. see contract.id, invoice_schedule, rolled_over_from, and various top level params. I believe it would be easier to use the sdk if these nil values were ommited as they are when you hit the api directly.

resp, err := metronome.sdkClient.Contracts.ListBalances(ctx, body)
b, _ := json.Marshal(resp)
fmt.Println(string(b))

output from sdk

{
   "data":[
      {
         "id":"08758227-6466-49e4-81b4-86838ac470bc",
         "contract":{
            "id":""
         },
         "type":"CREDIT",
         "name":"",
         "priority":100,
         "product":{
            "id":"e3051d31-92b8-412c-89a4-af3a12dc09fe",
            "name":"huh"
         },
         "access_schedule":{
            "schedule_items":[
               {
                  "id":"51f22b9b-7542-4300-80cd-92e3809b0a63",
                  "amount":12345,
                  "ending_before":"2024-11-03T00:00:00Z",
                  "starting_at":"2024-10-03T00:00:00Z"
               }
            ],
            "credit_type":"{\"id\":\"2714e483-4ff1-48e4-9e25-ac732e8f24f2\",\"name\":\"USD (cents)\"}"
         },
         "invoice_schedule":{
            "credit_type":"",
            "schedule_items":null
         },
         "invoice_contract":null,
         "rolled_over_from":null,
         "description":"",
         "rollover_fraction":0,
         "applicable_product_ids":null,
         "applicable_product_tags":null,
         "applicable_contract_ids":null,
         "netsuite_sales_order_id":"",
         "amount":0,
         "salesforce_opportunity_id":"",
         "ledger":[
            {
               "type":"CREDIT_SEGMENT_START",
               "timestamp":"2024-10-03T00:00:00Z",
               "amount":12345,
               "segment_id":"51f22b9b-7542-4300-80cd-92e3809b0a63",
               "invoice_id":"",
               "reason":""
            },
            {
               "type":"CREDIT_AUTOMATED_INVOICE_DEDUCTION",
               "timestamp":"2024-11-01T00:00:00Z",
               "amount":-12345,
               "segment_id":"51f22b9b-7542-4300-80cd-92e3809b0a63",
               "invoice_id":"e8da6d58-6216-51a3-992b-48e3a37f5c5c",
               "reason":""
            }
         ],
         "custom_fields":{
            
         }
      },
      {
         "id":"ea46efaa-a7e3-4ffb-a92f-e534197c8845",
         "contract":{
            "id":""
         },
         "type":"PREPAID",
         "name":"",
         "priority":100,
         "product":{
            "id":"e3051d31-92b8-412c-89a4-af3a12dc09fe",
            "name":"huh"
         },
         "access_schedule":{
            "schedule_items":[
               {
                  "id":"71173211-9a5b-4078-9a2a-6988ab6eb6f4",
                  "amount":10000,
                  "ending_before":"2024-11-03T00:00:00Z",
                  "starting_at":"2024-10-03T00:00:00Z"
               }
            ],
            "credit_type":"{\"id\":\"2714e483-4ff1-48e4-9e25-ac732e8f24f2\",\"name\":\"USD (cents)\"}"
         },
         "invoice_schedule":{
            "credit_type":"{\"id\":\"2714e483-4ff1-48e4-9e25-ac732e8f24f2\",\"name\":\"USD (cents)\"}",
            "schedule_items":[
               {
                  "id":"0603c322-68e2-4845-a7ec-572b4293addc",
                  "amount":2000,
                  "invoice_id":"74166a6f-a7c9-55c9-8aa5-7df4578a7604",
                  "quantity":1,
                  "timestamp":"2024-10-03T00:00:00Z",
                  "unit_price":2000
               }
            ]
         },
         "invoice_contract":{
            "id":"deeffc21-47a4-4115-80f9-57f03c042d71"
         },
         "rolled_over_from":{
            "commit_id":"",
            "contract_id":""
         },
         "description":"",
         "rollover_fraction":0,
         "applicable_product_ids":null,
         "applicable_product_tags":null,
         "applicable_contract_ids":null,
         "netsuite_sales_order_id":"",
         "amount":0,
         "salesforce_opportunity_id":"",
         "ledger":[
            {
               "type":"PREPAID_COMMIT_SEGMENT_START",
               "timestamp":"2024-10-03T00:00:00Z",
               "amount":10000,
               "segment_id":"71173211-9a5b-4078-9a2a-6988ab6eb6f4",
               "invoice_id":"",
               "new_contract_id":"",
               "reason":""
            },
            {
               "type":"PREPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION",
               "timestamp":"2024-11-01T00:00:00Z",
               "amount":-10000,
               "segment_id":"71173211-9a5b-4078-9a2a-6988ab6eb6f4",
               "invoice_id":"e8da6d58-6216-51a3-992b-48e3a37f5c5c",
               "new_contract_id":"",
               "reason":""
            }
         ],
         "custom_fields":{
            
         }
      },
      {
         "id":"abb9da9a-ab9c-4371-afbc-68722540110c",
         "contract":{
            "id":""
         },
         "type":"CREDIT",
         "name":"",
         "priority":100,
         "product":{
            "id":"e3051d31-92b8-412c-89a4-af3a12dc09fe",
            "name":"huh"
         },
         "access_schedule":{
            "schedule_items":[
               {
                  "id":"dc7f07c4-1cb4-4939-966b-6c560ea2235c",
                  "amount":1000000,
                  "ending_before":"2024-11-07T00:00:00Z",
                  "starting_at":"2024-10-07T00:00:00Z"
               }
            ],
            "credit_type":"{\"id\":\"2714e483-4ff1-48e4-9e25-ac732e8f24f2\",\"name\":\"USD (cents)\"}"
         },
         "invoice_schedule":{
            "credit_type":"",
            "schedule_items":null
         },
         "invoice_contract":null,
         "rolled_over_from":null,
         "description":"Credits to be used for aws",
         "rollover_fraction":0,
         "applicable_product_ids":[
            "2da2f3a2-5303-435f-b743-f43815fede99",
            "426e60f0-baee-478e-95a4-93c2bb8a08a9",
            "83fdee0b-058c-4b3a-8495-cad6708fad56",
            "fd726422-2baa-4aee-96c5-51339a8d64ab",
            "9747292a-5944-4f89-9c21-903faae429b0"
         ],
         "applicable_product_tags":null,
         "applicable_contract_ids":null,
         "netsuite_sales_order_id":"",
         "amount":0,
         "salesforce_opportunity_id":"",
         "ledger":[
            {
               "type":"CREDIT_SEGMENT_START",
               "timestamp":"2024-10-07T00:00:00Z",
               "amount":1000000,
               "segment_id":"dc7f07c4-1cb4-4939-966b-6c560ea2235c",
               "invoice_id":"",
               "reason":""
            }
         ],
         "custom_fields":{
            
         }
      }
   ],
   "next_page":""
}

output from direct api call

{
    "data": [
        {
            "id": "08758227-6466-49e4-81b4-86838ac470bc",
            "rate_type": "LIST_RATE",
            "product": {
                "id": "e3051d31-92b8-412c-89a4-af3a12dc09fe",
                "name": "huh"
            },
            "priority": 100,
            "access_schedule": {
                "credit_type": {
                    "id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
                    "name": "USD (cents)"
                },
                "schedule_items": [
                    {
                        "id": "51f22b9b-7542-4300-80cd-92e3809b0a63",
                        "amount": 12345,
                        "starting_at": "2024-10-03T00:00:00+00:00",
                        "ending_before": "2024-11-03T00:00:00+00:00"
                    }
                ]
            },
            "ledger": [
                {
                    "amount": 12345,
                    "timestamp": "2024-10-03T00:00:00+00:00",
                    "segment_id": "51f22b9b-7542-4300-80cd-92e3809b0a63",
                    "type": "CREDIT_SEGMENT_START"
                },
                {
                    "amount": -12345,
                    "timestamp": "2024-11-01T00:00:00+00:00",
                    "segment_id": "51f22b9b-7542-4300-80cd-92e3809b0a63",
                    "type": "CREDIT_AUTOMATED_INVOICE_DEDUCTION",
                    "invoice_id": "e8da6d58-6216-51a3-992b-48e3a37f5c5c"
                }
            ],
            "custom_fields": {},
            "type": "CREDIT"
        },
        {
            "id": "ea46efaa-a7e3-4ffb-a92f-e534197c8845",
            "rate_type": "LIST_RATE",
            "product": {
                "id": "e3051d31-92b8-412c-89a4-af3a12dc09fe",
                "name": "huh"
            },
            "priority": 100,
            "access_schedule": {
                "credit_type": {
                    "id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
                    "name": "USD (cents)"
                },
                "schedule_items": [
                    {
                        "id": "71173211-9a5b-4078-9a2a-6988ab6eb6f4",
                        "amount": 10000,
                        "starting_at": "2024-10-03T00:00:00+00:00",
                        "ending_before": "2024-11-03T00:00:00+00:00"
                    }
                ]
            },
            "ledger": [
                {
                    "amount": 10000,
                    "timestamp": "2024-10-03T00:00:00+00:00",
                    "segment_id": "71173211-9a5b-4078-9a2a-6988ab6eb6f4",
                    "type": "PREPAID_COMMIT_SEGMENT_START"
                },
                {
                    "amount": -10000,
                    "timestamp": "2024-11-01T00:00:00+00:00",
                    "segment_id": "71173211-9a5b-4078-9a2a-6988ab6eb6f4",
                    "type": "PREPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION",
                    "invoice_id": "e8da6d58-6216-51a3-992b-48e3a37f5c5c"
                }
            ],
            "custom_fields": {},
            "type": "PREPAID",
            "invoice_schedule": {
                "credit_type": {
                    "id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
                    "name": "USD (cents)"
                },
                "schedule_items": [
                    {
                        "id": "0603c322-68e2-4845-a7ec-572b4293addc",
                        "invoice_id": "74166a6f-a7c9-55c9-8aa5-7df4578a7604",
                        "amount": 2000,
                        "unit_price": 2000,
                        "quantity": 1,
                        "timestamp": "2024-10-03T00:00:00+00:00"
                    }
                ]
            },
            "invoice_contract": {
                "id": "deeffc21-47a4-4115-80f9-57f03c042d71"
            }
        },
        {
            "id": "abb9da9a-ab9c-4371-afbc-68722540110c",
            "rate_type": "LIST_RATE",
            "product": {
                "id": "e3051d31-92b8-412c-89a4-af3a12dc09fe",
                "name": "huh"
            },
            "description": "Credits to be used for aws",
            "priority": 100,
            "applicable_product_ids": [
                "2da2f3a2-5303-435f-b743-f43815fede99",
                "426e60f0-baee-478e-95a4-93c2bb8a08a9",
                "83fdee0b-058c-4b3a-8495-cad6708fad56",
                "fd726422-2baa-4aee-96c5-51339a8d64ab",
                "9747292a-5944-4f89-9c21-903faae429b0"
            ],
            "access_schedule": {
                "credit_type": {
                    "id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
                    "name": "USD (cents)"
                },
                "schedule_items": [
                    {
                        "id": "dc7f07c4-1cb4-4939-966b-6c560ea2235c",
                        "amount": 1000000,
                        "starting_at": "2024-10-07T00:00:00+00:00",
                        "ending_before": "2024-11-07T00:00:00+00:00"
                    }
                ]
            },
            "ledger": [
                {
                    "amount": 1000000,
                    "timestamp": "2024-10-07T00:00:00+00:00",
                    "segment_id": "dc7f07c4-1cb4-4939-966b-6c560ea2235c",
                    "type": "CREDIT_SEGMENT_START"
                }
            ],
            "custom_fields": {},
            "type": "CREDIT"
        }
    ],
    "next_page": null
}
@aliotta aliotta changed the title Nil values not ommitted Nil values not ommitted in sdk api calls Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant