metronome-sdk 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +55 -0
  3. data/README.md +1 -1
  4. data/lib/metronome_sdk/errors.rb +25 -11
  5. data/lib/metronome_sdk/file_part.rb +10 -7
  6. data/lib/metronome_sdk/internal/body_cursor_page.rb +1 -1
  7. data/lib/metronome_sdk/internal/cursor_page.rb +1 -1
  8. data/lib/metronome_sdk/internal/cursor_page_without_limit.rb +1 -1
  9. data/lib/metronome_sdk/internal/transport/base_client.rb +11 -7
  10. data/lib/metronome_sdk/internal/transport/pooled_net_requester.rb +7 -10
  11. data/lib/metronome_sdk/internal/type/base_page.rb +1 -1
  12. data/lib/metronome_sdk/internal/type/enum.rb +25 -0
  13. data/lib/metronome_sdk/internal/type/file_input.rb +7 -4
  14. data/lib/metronome_sdk/internal/util.rb +8 -7
  15. data/lib/metronome_sdk/models/contract_v2.rb +256 -6
  16. data/lib/metronome_sdk/models/contract_without_amendments.rb +2 -2
  17. data/lib/metronome_sdk/models/hierarchy_configuration.rb +99 -2
  18. data/lib/metronome_sdk/models/payment_gate_config.rb +1 -0
  19. data/lib/metronome_sdk/models/payment_gate_config_v2.rb +1 -0
  20. data/lib/metronome_sdk/models/subscription.rb +85 -1
  21. data/lib/metronome_sdk/models/v1/alert_archive_params.rb +8 -4
  22. data/lib/metronome_sdk/models/v1/alert_create_params.rb +38 -36
  23. data/lib/metronome_sdk/models/v1/contract_amend_params.rb +1 -0
  24. data/lib/metronome_sdk/models/v1/contract_create_params.rb +101 -3
  25. data/lib/metronome_sdk/models/v1/customer_detail.rb +9 -1
  26. data/lib/metronome_sdk/models/v1/customer_preview_events_params.rb +5 -15
  27. data/lib/metronome_sdk/models/v1/customer_preview_events_response.rb +3 -3
  28. data/lib/metronome_sdk/models/v1/customers/alert_list_params.rb +3 -3
  29. data/lib/metronome_sdk/models/v1/customers/alert_reset_params.rb +2 -2
  30. data/lib/metronome_sdk/models/v1/customers/alert_retrieve_params.rb +12 -12
  31. data/lib/metronome_sdk/models/v1/customers/customer_alert.rb +40 -38
  32. data/lib/metronome_sdk/models/v1/customers/invoice.rb +136 -18
  33. data/lib/metronome_sdk/models/v1/customers/invoice_retrieve_pdf_params.rb +30 -0
  34. data/lib/metronome_sdk/models/v1/payment.rb +151 -0
  35. data/lib/metronome_sdk/models/v1/payment_attempt_params.rb +28 -0
  36. data/lib/metronome_sdk/models/v1/payment_attempt_response.rb +18 -0
  37. data/lib/metronome_sdk/models/v1/payment_cancel_params.rb +28 -0
  38. data/lib/metronome_sdk/models/v1/payment_cancel_response.rb +18 -0
  39. data/lib/metronome_sdk/models/v1/payment_list_params.rb +53 -0
  40. data/lib/metronome_sdk/models/v1/payment_status.rb +19 -0
  41. data/lib/metronome_sdk/models/v2/contract_edit_commit_params.rb +9 -1
  42. data/lib/metronome_sdk/models/v2/contract_edit_credit_params.rb +9 -1
  43. data/lib/metronome_sdk/models/v2/contract_edit_params.rb +186 -3
  44. data/lib/metronome_sdk/models/v2/contract_get_edit_history_response.rb +195 -8
  45. data/lib/metronome_sdk/resources/v1/alerts.rb +57 -53
  46. data/lib/metronome_sdk/resources/v1/contracts.rb +4 -3
  47. data/lib/metronome_sdk/resources/v1/customers/alerts.rb +70 -51
  48. data/lib/metronome_sdk/resources/v1/customers/invoices.rb +55 -0
  49. data/lib/metronome_sdk/resources/v1/customers.rb +7 -4
  50. data/lib/metronome_sdk/resources/v1/payments.rb +102 -0
  51. data/lib/metronome_sdk/resources/v1/usage.rb +4 -2
  52. data/lib/metronome_sdk/resources/v1.rb +4 -0
  53. data/lib/metronome_sdk/resources/v2/contracts.rb +9 -3
  54. data/lib/metronome_sdk/version.rb +1 -1
  55. data/lib/metronome_sdk.rb +9 -0
  56. data/rbi/metronome_sdk/errors.rbi +29 -2
  57. data/rbi/metronome_sdk/file_part.rbi +1 -1
  58. data/rbi/metronome_sdk/internal/transport/base_client.rbi +4 -5
  59. data/rbi/metronome_sdk/internal/type/base_page.rbi +1 -1
  60. data/rbi/metronome_sdk/internal/util.rbi +1 -1
  61. data/rbi/metronome_sdk/models/contract_v2.rbi +603 -10
  62. data/rbi/metronome_sdk/models/contract_without_amendments.rbi +2 -2
  63. data/rbi/metronome_sdk/models/hierarchy_configuration.rbi +250 -6
  64. data/rbi/metronome_sdk/models/payment_gate_config.rbi +5 -0
  65. data/rbi/metronome_sdk/models/payment_gate_config_v2.rbi +5 -0
  66. data/rbi/metronome_sdk/models/subscription.rbi +175 -0
  67. data/rbi/metronome_sdk/models/v1/alert_archive_params.rbi +6 -4
  68. data/rbi/metronome_sdk/models/v1/alert_create_params.rbi +51 -47
  69. data/rbi/metronome_sdk/models/v1/contract_amend_params.rbi +5 -0
  70. data/rbi/metronome_sdk/models/v1/contract_create_params.rbi +257 -4
  71. data/rbi/metronome_sdk/models/v1/customer_detail.rbi +8 -0
  72. data/rbi/metronome_sdk/models/v1/customer_preview_events_params.rbi +6 -21
  73. data/rbi/metronome_sdk/models/v1/customer_preview_events_response.rbi +10 -9
  74. data/rbi/metronome_sdk/models/v1/customers/alert_list_params.rbi +4 -4
  75. data/rbi/metronome_sdk/models/v1/customers/alert_reset_params.rbi +2 -2
  76. data/rbi/metronome_sdk/models/v1/customers/alert_retrieve_params.rbi +14 -14
  77. data/rbi/metronome_sdk/models/v1/customers/customer_alert.rbi +48 -44
  78. data/rbi/metronome_sdk/models/v1/customers/invoice.rbi +246 -58
  79. data/rbi/metronome_sdk/models/v1/customers/invoice_retrieve_pdf_params.rbi +50 -0
  80. data/rbi/metronome_sdk/models/v1/payment.rbi +316 -0
  81. data/rbi/metronome_sdk/models/v1/payment_attempt_params.rbi +48 -0
  82. data/rbi/metronome_sdk/models/v1/payment_attempt_response.rbi +35 -0
  83. data/rbi/metronome_sdk/models/v1/payment_cancel_params.rbi +48 -0
  84. data/rbi/metronome_sdk/models/v1/payment_cancel_response.rbi +35 -0
  85. data/rbi/metronome_sdk/models/v1/payment_list_params.rbi +91 -0
  86. data/rbi/metronome_sdk/models/v1/payment_status.rbi +33 -0
  87. data/rbi/metronome_sdk/models/v2/contract_edit_commit_params.rbi +18 -0
  88. data/rbi/metronome_sdk/models/v2/contract_edit_credit_params.rbi +18 -0
  89. data/rbi/metronome_sdk/models/v2/contract_edit_params.rbi +498 -6
  90. data/rbi/metronome_sdk/models/v2/contract_get_edit_history_response.rbi +462 -14
  91. data/rbi/metronome_sdk/resources/v1/alerts.rbi +68 -64
  92. data/rbi/metronome_sdk/resources/v1/contracts.rbi +4 -3
  93. data/rbi/metronome_sdk/resources/v1/customers/alerts.rbi +73 -54
  94. data/rbi/metronome_sdk/resources/v1/customers/invoices.rbi +36 -0
  95. data/rbi/metronome_sdk/resources/v1/customers.rbi +7 -4
  96. data/rbi/metronome_sdk/resources/v1/payments.rbi +72 -0
  97. data/rbi/metronome_sdk/resources/v1/usage.rbi +4 -2
  98. data/rbi/metronome_sdk/resources/v1.rbi +3 -0
  99. data/rbi/metronome_sdk/resources/v2/contracts.rbi +14 -0
  100. data/sig/metronome_sdk/errors.rbs +7 -0
  101. data/sig/metronome_sdk/file_part.rbs +1 -1
  102. data/sig/metronome_sdk/models/contract_v2.rbs +239 -12
  103. data/sig/metronome_sdk/models/hierarchy_configuration.rbs +87 -6
  104. data/sig/metronome_sdk/models/payment_gate_config.rbs +2 -1
  105. data/sig/metronome_sdk/models/payment_gate_config_v2.rbs +2 -1
  106. data/sig/metronome_sdk/models/subscription.rbs +80 -0
  107. data/sig/metronome_sdk/models/v1/contract_amend_params.rbs +2 -1
  108. data/sig/metronome_sdk/models/v1/contract_create_params.rbs +91 -5
  109. data/sig/metronome_sdk/models/v1/customer_detail.rbs +5 -0
  110. data/sig/metronome_sdk/models/v1/customer_preview_events_params.rbs +0 -7
  111. data/sig/metronome_sdk/models/v1/customer_preview_events_response.rbs +6 -4
  112. data/sig/metronome_sdk/models/v1/customers/invoice.rbs +137 -24
  113. data/sig/metronome_sdk/models/v1/customers/invoice_retrieve_pdf_params.rbs +32 -0
  114. data/sig/metronome_sdk/models/v1/payment.rbs +191 -0
  115. data/sig/metronome_sdk/models/v1/payment_attempt_params.rbs +30 -0
  116. data/sig/metronome_sdk/models/v1/payment_attempt_response.rbs +15 -0
  117. data/sig/metronome_sdk/models/v1/payment_cancel_params.rbs +30 -0
  118. data/sig/metronome_sdk/models/v1/payment_cancel_response.rbs +15 -0
  119. data/sig/metronome_sdk/models/v1/payment_list_params.rbs +56 -0
  120. data/sig/metronome_sdk/models/v1/payment_status.rbs +19 -0
  121. data/sig/metronome_sdk/models/v2/contract_edit_commit_params.rbs +9 -0
  122. data/sig/metronome_sdk/models/v2/contract_edit_credit_params.rbs +9 -0
  123. data/sig/metronome_sdk/models/v2/contract_edit_params.rbs +182 -7
  124. data/sig/metronome_sdk/models/v2/contract_get_edit_history_response.rbs +221 -18
  125. data/sig/metronome_sdk/resources/v1/customers/invoices.rbs +6 -0
  126. data/sig/metronome_sdk/resources/v1/payments.rbs +30 -0
  127. data/sig/metronome_sdk/resources/v1.rbs +2 -0
  128. data/sig/metronome_sdk/resources/v2/contracts.rbs +3 -0
  129. metadata +29 -2
@@ -8,17 +8,26 @@ module MetronomeSDK
8
8
  # Some parameter documentations has been truncated, see
9
9
  # {MetronomeSDK::Models::V1::Customers::AlertRetrieveParams} for more details.
10
10
  #
11
- # Retrieve the real-time evaluation status for a specific alert-customer pair.
12
- # This endpoint provides instant visibility into whether a customer has triggered
13
- # an alert condition, enabling you to monitor account health and take proactive
14
- # action based on current alert states.
11
+ # Retrieve the real-time evaluation status for a specific threshold
12
+ # notification-customer pair. This endpoint provides instant visibility into
13
+ # whether a customer has triggered a threshold notification condition, enabling
14
+ # you to monitor account health and take proactive action based on current
15
+ # threshold notification states.
15
16
  #
16
17
  # ### Use this endpoint to:
17
18
  #
18
- # - Check if a specific customer is currently violating an alert threshold
19
+ # - Check if a specific customer is currently violating an threshold notification
19
20
  # (`in_alarm` status)
20
- # - Verify alert configuration details and threshold values for a customer
21
- # - Integrate alert status checks into customer support tools or admin interfaces
21
+ # - Verify threshold notification configuration details and threshold values for a
22
+ # customer
23
+ # - Monitor the evaluation state of newly created or recently modified threshold
24
+ # notification
25
+ # - Build dashboards or automated workflows that respond to specific threshold
26
+ # notification conditions
27
+ # - Validate threshold notification behavior before deploying to production
28
+ # customers
29
+ # - Integrate threshold notification status checks into customer support tools or
30
+ # admin interfaces
22
31
  #
23
32
  # ### Key response fields:
24
33
  #
@@ -27,40 +36,43 @@ module MetronomeSDK
27
36
  # - `customer_status`: The current evaluation state
28
37
  #
29
38
  # - `ok` - Customer is within acceptable thresholds
30
- # - `in_alarm`- Customer has breached the alert threshold
31
- # - `evaluating` - Alert has yet to be evaluated (typically due to a customer or
32
- # alert having just been created)
33
- # - `null` - Alert has been archived
34
- # - `triggered_by`: Additional context about what caused the alert to trigger
35
- # (when applicable)
36
- # - alert: Complete alert configuration including:
37
- # - Alert ID, name, and type
39
+ # - `in_alarm` - Customer has breached the threshold for the notification
40
+ # - `evaluating` - Notification is currently being evaluated (typically during
41
+ # initial setup)
42
+ # - `null` - Notification has been archived
43
+ # - `triggered_by`: Additional context about what caused the notification to
44
+ # trigger (when applicable)
45
+ # - alert: Complete threshold notification configuration including:
46
+ # - Notification ID, name, and type
38
47
  # - Current threshold values and credit type information
39
- # - Alert status (enabled, disabled, or archived)
48
+ # - Notification status (enabled, disabled, or archived)
40
49
  # - Last update timestamp
41
50
  # - Any applied filters (credit grant types, custom fields, group values)
42
51
  #
43
52
  # ### Usage guidelines:
44
53
  #
45
54
  # - Customer status: Returns the current evaluation state, not historical data.
46
- # For alert history, use webhook notifications or event logs
47
- # - Archived alerts: Returns null for customer_status if the alert has been
48
- # archived, but still includes the alert configuration details
49
- # - Integration patterns: This endpoint can be used to check a customer's alert
50
- # status, but shouldn't be scraped. You should instead rely on the webhook
51
- # notification to understand when customers are moved to IN_ALARM.
52
- # - Error handling: Returns 404 if either the customer or alert ID doesn't exist
55
+ # For threshold notification history, use webhook notifications or event logs
56
+ # - Required parameters: Both customer_id and alert_id must be valid UUIDs that
57
+ # exist in your organization
58
+ # - Archived notifications: Returns null for customer_status if the notification
59
+ # has been archived, but still includes the notification configuration details
60
+ # - Performance considerations: This endpoint queries live evaluation state,
61
+ # making it ideal for real-time monitoring but not for bulk status checks
62
+ # - Integration patterns: Best used for on-demand status checks in response to
63
+ # user actions or as part of targeted monitoring workflows
64
+ # - Error handling: Returns 404 if either the customer or alert_id doesn't exist
53
65
  # or isn't accessible to your organization
54
66
  #
55
67
  # @overload retrieve(alert_id:, customer_id:, group_values: nil, plans_or_contracts: nil, request_options: {})
56
68
  #
57
- # @param alert_id [String] The Metronome ID of the alert
69
+ # @param alert_id [String] The Metronome ID of the threshold notification
58
70
  #
59
71
  # @param customer_id [String] The Metronome ID of the customer
60
72
  #
61
- # @param group_values [Array<MetronomeSDK::Models::V1::Customers::AlertRetrieveParams::GroupValue>] Only present for `spend_threshold_reached` alerts. Retrieve the alert for a spec
73
+ # @param group_values [Array<MetronomeSDK::Models::V1::Customers::AlertRetrieveParams::GroupValue>] Only present for `spend_threshold_reached` notifications. Retrieve the notificat
62
74
  #
63
- # @param plans_or_contracts [Symbol, MetronomeSDK::Models::V1::Customers::AlertRetrieveParams::PlansOrContracts] When parallel alerts are enabled during migration, this flag denotes whether to
75
+ # @param plans_or_contracts [Symbol, MetronomeSDK::Models::V1::Customers::AlertRetrieveParams::PlansOrContracts] When parallel threshold notifications are enabled during migration, this flag de
64
76
  #
65
77
  # @param request_options [MetronomeSDK::RequestOptions, Hash{Symbol=>Object}, nil]
66
78
  #
@@ -81,31 +93,37 @@ module MetronomeSDK
81
93
  # Some parameter documentations has been truncated, see
82
94
  # {MetronomeSDK::Models::V1::Customers::AlertListParams} for more details.
83
95
  #
84
- # Retrieve all alert configurations and their current statuses for a specific
85
- # customer in a single API call. This endpoint provides a comprehensive view of
86
- # all alerts monitoring a customer account.
96
+ # Retrieve all threshold notification configurations and their current statuses
97
+ # for a specific customer in a single API call. This endpoint provides a
98
+ # comprehensive view of all threshold notification monitoring a customer account.
87
99
  #
88
100
  # ### Use this endpoint to:
89
101
  #
90
- # - Display all active alerts for a customer in dashboards or admin panels
91
- # - Quickly identify which alerts a customer is currently triggering
92
- # - Audit alert coverage for specific accounts
93
- # - Filter alerts by status (enabled, disabled, or archived)
102
+ # - Display all active threshold notifications for a customer in dashboards or
103
+ # admin panels
104
+ # - Quickly identify which threshold notifications a customer is currently
105
+ # triggering
106
+ # - Audit threshold notification coverage for specific accounts
107
+ # - Filter threshold notifications by status (enabled, disabled, or archived)
94
108
  #
95
109
  # ### Key response fields:
96
110
  #
97
111
  # - data: Array of CustomerAlert objects, each containing:
98
112
  # - Current evaluation status (`ok`, `in_alarm`, `evaluating`, or `null`)
99
- # - Complete alert configuration and threshold details
100
- # - Alert metadata including type, name, and last update time
101
- # - `next_page`: Pagination cursor for retrieving additional results
113
+ # - Complete threshold notification configuration and threshold details
114
+ # - Threshold notification metadata including type, name, and last update time
115
+ # - next_page: Pagination cursor for retrieving additional results
102
116
  #
103
117
  # ### Usage guidelines:
104
118
  #
105
- # - Default behavior: Returns only enabled alerts unless alert_statuses filter is
106
- # specified
119
+ # - Default behavior: Returns only enabled threshold notifications unless
120
+ # `alert_statuses` filter is specified
107
121
  # - Pagination: Use the `next_page` cursor to retrieve all results for customers
108
- # with many alerts
122
+ # with many notifications
123
+ # - Performance: Efficiently retrieves multiple threshold notification statuses in
124
+ # a single request instead of making individual calls
125
+ # - Filtering: Pass the `alert_statuses` array to include disabled or archived
126
+ # threshold notifications in results
109
127
  #
110
128
  # @overload list(customer_id:, next_page: nil, alert_statuses: nil, request_options: {})
111
129
  #
@@ -113,7 +131,7 @@ module MetronomeSDK
113
131
  #
114
132
  # @param next_page [String] Query param: Cursor that indicates where the next page of results should start.
115
133
  #
116
- # @param alert_statuses [Array<Symbol, MetronomeSDK::Models::V1::Customers::AlertListParams::AlertStatus>] Body param: Optionally filter by alert status. If absent, only enabled alerts wi
134
+ # @param alert_statuses [Array<Symbol, MetronomeSDK::Models::V1::Customers::AlertListParams::AlertStatus>] Body param: Optionally filter by threshold notification status. If absent, only
117
135
  #
118
136
  # @param request_options [MetronomeSDK::RequestOptions, Hash{Symbol=>Object}, nil]
119
137
  #
@@ -134,23 +152,24 @@ module MetronomeSDK
134
152
  )
135
153
  end
136
154
 
137
- # Force an immediate re-evaluation of a specific alert for a customer, clearing
138
- # any previous state and triggering a fresh assessment against current thresholds.
139
- # This endpoint ensures alert accuracy after configuration changes or data
140
- # corrections.
155
+ # Force an immediate re-evaluation of a specific threshold notification for a
156
+ # customer, clearing any previous state and triggering a fresh assessment against
157
+ # current thresholds. This endpoint ensures threshold notification accuracy after
158
+ # configuration changes or data corrections.
141
159
  #
142
160
  # ### Use this endpoint to:
143
161
  #
144
- # - Clear false positive alerts after fixing data issues
145
- # - Re-evaluate alerts after adjusting customer balances or credits
146
- # - Test alert behavior during development and debugging
147
- # - Resolve stuck alerts that may be in an incorrect state
162
+ # - Clear false positive threshold notifications after fixing data issues
163
+ # - Re-evaluate threshold notifications after adjusting customer balances or
164
+ # credits
165
+ # - Test threshold notification behavior during development and debugging
166
+ # - Resolve stuck threshold notification that may be in an incorrect state
148
167
  # - Trigger immediate evaluation after threshold modifications
149
168
  #
150
169
  # ### Key response fields:
151
170
  #
152
- # - 200 Success: Confirmation that the alert has been reset and re-evaluation
153
- # initiated
171
+ # - 200 Success: Confirmation that the threshold notification has been reset and
172
+ # re-evaluation initiated
154
173
  # - No response body is returned - the operation completes asynchronously
155
174
  #
156
175
  # ### Usage guidelines:
@@ -165,7 +184,7 @@ module MetronomeSDK
165
184
  #
166
185
  # @overload reset(alert_id:, customer_id:, request_options: {})
167
186
  #
168
- # @param alert_id [String] The Metronome ID of the alert
187
+ # @param alert_id [String] The Metronome ID of the threshold notification
169
188
  #
170
189
  # @param customer_id [String] The Metronome ID of the customer
171
190
  #
@@ -299,6 +299,61 @@ module MetronomeSDK
299
299
  )
300
300
  end
301
301
 
302
+ # Retrieve a PDF version of a specific invoice by its unique identifier. This
303
+ # endpoint generates a professionally formatted invoice document suitable for
304
+ # sharing with customers, accounting teams, or for record-keeping purposes.
305
+ #
306
+ # ### Use this endpoint to:
307
+ #
308
+ # - Provide customers with downloadable or emailable copies of their invoices
309
+ # - Support accounting and finance teams with official billing documents
310
+ # - Maintain accurate records of billing transactions for audits and compliance
311
+ #
312
+ # ### Key response details:
313
+ #
314
+ # - The response is a binary PDF file representing the full invoice
315
+ # - The PDF includes all standard invoice information such as line items, totals,
316
+ # billing period, and customer details
317
+ # - The document is formatted for clarity and professionalism, suitable for
318
+ # official use
319
+ #
320
+ # ### Usage guidelines:
321
+ #
322
+ # - Ensure the `invoice_id` corresponds to an existing invoice for the specified
323
+ # `customer_id`
324
+ # - The PDF is generated on-demand; frequent requests for the same invoice may
325
+ # impact performance
326
+ # - Use appropriate headers to handle the binary response in your application
327
+ # (e.g., setting `Content-Type: application/pdf`)
328
+ #
329
+ # @overload retrieve_pdf(customer_id:, invoice_id:, request_options: {})
330
+ #
331
+ # @param customer_id [String]
332
+ # @param invoice_id [String]
333
+ # @param request_options [MetronomeSDK::RequestOptions, Hash{Symbol=>Object}, nil]
334
+ #
335
+ # @return [StringIO]
336
+ #
337
+ # @see MetronomeSDK::Models::V1::Customers::InvoiceRetrievePdfParams
338
+ def retrieve_pdf(params)
339
+ parsed, options = MetronomeSDK::V1::Customers::InvoiceRetrievePdfParams.dump_request(params)
340
+ customer_id =
341
+ parsed.delete(:customer_id) do
342
+ raise ArgumentError.new("missing required path argument #{_1}")
343
+ end
344
+ invoice_id =
345
+ parsed.delete(:invoice_id) do
346
+ raise ArgumentError.new("missing required path argument #{_1}")
347
+ end
348
+ @client.request(
349
+ method: :get,
350
+ path: ["v1/customers/%1$s/invoices/%2$s/pdf", customer_id, invoice_id],
351
+ headers: {"accept" => "application/pdf"},
352
+ model: StringIO,
353
+ options: options
354
+ )
355
+ end
356
+
302
357
  # @api private
303
358
  #
304
359
  # @param client [MetronomeSDK::Client]
@@ -176,7 +176,7 @@ module MetronomeSDK
176
176
  # - Ingest aliases remain idempotent for archived customers. In order to reuse an
177
177
  # ingest alias, first remove the ingest alias from the customer prior to
178
178
  # archiving.
179
- # - Any alerts associated with the customer will no longer be triggered.
179
+ # - Any notifications associated with the customer will no longer be triggered.
180
180
  #
181
181
  # @overload archive(id:, request_options: {})
182
182
  #
@@ -278,10 +278,10 @@ module MetronomeSDK
278
278
  # Some parameter documentations has been truncated, see
279
279
  # {MetronomeSDK::Models::V1::CustomerPreviewEventsParams} for more details.
280
280
  #
281
- # Preview how a set of events will affect a customer's invoice. Generates a draft
282
- # invoice for a customer using their current contract configuration and the
281
+ # Preview how a set of events will affect a customer's invoices. Generates draft
282
+ # invoices for a customer using their current contract configuration and the
283
283
  # provided events. This is useful for testing how new events will affect the
284
- # customer's invoice before they are actually processed.
284
+ # customer's invoices before they are actually processed.
285
285
  #
286
286
  # @overload preview_events(customer_id:, events:, mode: nil, skip_zero_qty_line_items: nil, request_options: {})
287
287
  #
@@ -353,6 +353,9 @@ module MetronomeSDK
353
353
  # through system A (e.g. Stripe) but will now be billed through system B (e.g.
354
354
  # AWS). Once created, the new configuration can then be associated to the
355
355
  # customer's contract.
356
+ # - Multiple configurations can be added per destination. For example, you can
357
+ # create two Stripe billing configurations for a Metronome customer that each
358
+ # have a distinct `collection_method`.
356
359
  #
357
360
  # ### Delivery method options:
358
361
  #
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MetronomeSDK
4
+ module Resources
5
+ class V1
6
+ class Payments
7
+ # Fetch all payment attempts for the given invoice.
8
+ #
9
+ # @overload list(customer_id:, invoice_id:, limit: nil, next_page: nil, statuses: nil, request_options: {})
10
+ #
11
+ # @param customer_id [String]
12
+ #
13
+ # @param invoice_id [String]
14
+ #
15
+ # @param limit [Integer] The maximum number of payments to return. Defaults to 25.
16
+ #
17
+ # @param next_page [String] The next page token from a previous response.
18
+ #
19
+ # @param statuses [Array<Symbol, MetronomeSDK::Models::V1::PaymentStatus>]
20
+ #
21
+ # @param request_options [MetronomeSDK::RequestOptions, Hash{Symbol=>Object}, nil]
22
+ #
23
+ # @return [MetronomeSDK::Internal::BodyCursorPage<MetronomeSDK::Models::V1::Payment>]
24
+ #
25
+ # @see MetronomeSDK::Models::V1::PaymentListParams
26
+ def list(params)
27
+ parsed, options = MetronomeSDK::V1::PaymentListParams.dump_request(params)
28
+ @client.request(
29
+ method: :post,
30
+ path: "v1/payments/list",
31
+ body: parsed,
32
+ page: MetronomeSDK::Internal::BodyCursorPage,
33
+ model: MetronomeSDK::V1::Payment,
34
+ options: options
35
+ )
36
+ end
37
+
38
+ # Trigger a new attempt by canceling any existing attempts for this invoice and
39
+ # creating a new Payment. This will trigger another attempt to charge the
40
+ # Customer's configured Payment Gateway. Payment can only be attempted if all of
41
+ # the following are true:
42
+ #
43
+ # - The Metronome Invoice is finalized
44
+ # - PLG Invoicing is configured for the Customer
45
+ # - You cannot attempt payments for invoices that have already been `paid` or
46
+ # `voided`.
47
+ #
48
+ # Attempting to payment on an ineligible Invoice or Customer will result in a
49
+ # `400` response.
50
+ #
51
+ # @overload attempt(customer_id:, invoice_id:, request_options: {})
52
+ #
53
+ # @param customer_id [String]
54
+ # @param invoice_id [String]
55
+ # @param request_options [MetronomeSDK::RequestOptions, Hash{Symbol=>Object}, nil]
56
+ #
57
+ # @return [MetronomeSDK::Models::V1::PaymentAttemptResponse]
58
+ #
59
+ # @see MetronomeSDK::Models::V1::PaymentAttemptParams
60
+ def attempt(params)
61
+ parsed, options = MetronomeSDK::V1::PaymentAttemptParams.dump_request(params)
62
+ @client.request(
63
+ method: :post,
64
+ path: "v1/payments/attempt",
65
+ body: parsed,
66
+ model: MetronomeSDK::Models::V1::PaymentAttemptResponse,
67
+ options: options
68
+ )
69
+ end
70
+
71
+ # Cancel an existing payment attempt for an invoice.
72
+ #
73
+ # @overload cancel(customer_id:, invoice_id:, request_options: {})
74
+ #
75
+ # @param customer_id [String]
76
+ # @param invoice_id [String]
77
+ # @param request_options [MetronomeSDK::RequestOptions, Hash{Symbol=>Object}, nil]
78
+ #
79
+ # @return [MetronomeSDK::Models::V1::PaymentCancelResponse]
80
+ #
81
+ # @see MetronomeSDK::Models::V1::PaymentCancelParams
82
+ def cancel(params)
83
+ parsed, options = MetronomeSDK::V1::PaymentCancelParams.dump_request(params)
84
+ @client.request(
85
+ method: :post,
86
+ path: "v1/payments/cancel",
87
+ body: parsed,
88
+ model: MetronomeSDK::Models::V1::PaymentCancelResponse,
89
+ options: options
90
+ )
91
+ end
92
+
93
+ # @api private
94
+ #
95
+ # @param client [MetronomeSDK::Client]
96
+ def initialize(client:)
97
+ @client = client
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -80,8 +80,7 @@ module MetronomeSDK
80
80
  # ingestion, supports backdating 34 days, and is built to handle mission-critical
81
81
  # usage data with enterprise-grade reliability. Metronome supports 100,000 events
82
82
  # per second without requiring pre-aggregation or rollups and can scale up from
83
- # there. See
84
- # [Getting usage into Metronome](https://docs.metronome.com/connect-metronome/) to
83
+ # there. See the [Send usage events](/guides/events/send-usage-events) guide to
85
84
  # learn more about usage events.
86
85
  #
87
86
  # ### Use this endpoint to:
@@ -124,6 +123,9 @@ module MetronomeSDK
124
123
  # }
125
124
  # ```
126
125
  #
126
+ # Learn more about
127
+ # [usage event structure definitions](/guides/events/design-usage-events).
128
+ #
127
129
  # #### Transaction ID
128
130
  #
129
131
  # The transaction_id serves as your idempotency key, ensuring events are processed
@@ -42,6 +42,9 @@ module MetronomeSDK
42
42
  # @return [MetronomeSDK::Resources::V1::Contracts]
43
43
  attr_reader :contracts
44
44
 
45
+ # @return [MetronomeSDK::Resources::V1::Payments]
46
+ attr_reader :payments
47
+
45
48
  # @api private
46
49
  #
47
50
  # @param client [MetronomeSDK::Client]
@@ -60,6 +63,7 @@ module MetronomeSDK
60
63
  @services = MetronomeSDK::Resources::V1::Services.new(client: client)
61
64
  @invoices = MetronomeSDK::Resources::V1::Invoices.new(client: client)
62
65
  @contracts = MetronomeSDK::Resources::V1::Contracts.new(client: client)
66
+ @payments = MetronomeSDK::Resources::V1::Payments.new(client: client)
63
67
  end
64
68
  end
65
69
  end
@@ -128,12 +128,14 @@ module MetronomeSDK
128
128
  # - Contract editing must be enabled to use this endpoint. Reach out to your
129
129
  # Metronome representative to learn more.
130
130
  #
131
- # @overload edit(contract_id:, customer_id:, add_commits: nil, add_credits: nil, add_discounts: nil, add_overrides: nil, add_prepaid_balance_threshold_configuration: nil, add_professional_services: nil, add_recurring_commits: nil, add_recurring_credits: nil, add_reseller_royalties: nil, add_scheduled_charges: nil, add_spend_threshold_configuration: nil, add_subscriptions: nil, allow_contract_ending_before_finalized_invoice: nil, archive_commits: nil, archive_credits: nil, archive_scheduled_charges: nil, remove_overrides: nil, uniqueness_key: nil, update_commits: nil, update_contract_end_date: nil, update_contract_name: nil, update_credits: nil, update_prepaid_balance_threshold_configuration: nil, update_recurring_commits: nil, update_recurring_credits: nil, update_scheduled_charges: nil, update_spend_threshold_configuration: nil, update_subscriptions: nil, request_options: {})
131
+ # @overload edit(contract_id:, customer_id:, add_billing_provider_configuration_update: nil, add_commits: nil, add_credits: nil, add_discounts: nil, add_overrides: nil, add_prepaid_balance_threshold_configuration: nil, add_professional_services: nil, add_recurring_commits: nil, add_recurring_credits: nil, add_reseller_royalties: nil, add_scheduled_charges: nil, add_spend_threshold_configuration: nil, add_subscriptions: nil, allow_contract_ending_before_finalized_invoice: nil, archive_commits: nil, archive_credits: nil, archive_scheduled_charges: nil, remove_overrides: nil, uniqueness_key: nil, update_commits: nil, update_contract_end_date: nil, update_contract_name: nil, update_credits: nil, update_prepaid_balance_threshold_configuration: nil, update_recurring_commits: nil, update_recurring_credits: nil, update_scheduled_charges: nil, update_spend_threshold_configuration: nil, update_subscriptions: nil, request_options: {})
132
132
  #
133
133
  # @param contract_id [String] ID of the contract being edited
134
134
  #
135
135
  # @param customer_id [String] ID of the customer whose contract is being edited
136
136
  #
137
+ # @param add_billing_provider_configuration_update [MetronomeSDK::Models::V2::ContractEditParams::AddBillingProviderConfigurationUpdate] Update the billing provider configuration on the contract. Currently only suppor
138
+ #
137
139
  # @param add_commits [Array<MetronomeSDK::Models::V2::ContractEditParams::AddCommit>]
138
140
  #
139
141
  # @param add_credits [Array<MetronomeSDK::Models::V2::ContractEditParams::AddCredit>]
@@ -226,7 +228,7 @@ module MetronomeSDK
226
228
  # finalized invoice. You can void the invoice beforehand and then remove the
227
229
  # access schedule segment.
228
230
  #
229
- # @overload edit_commit(commit_id:, customer_id:, access_schedule: nil, applicable_product_ids: nil, applicable_product_tags: nil, invoice_contract_id: nil, invoice_schedule: nil, priority: nil, product_id: nil, rate_type: nil, specifiers: nil, request_options: {})
231
+ # @overload edit_commit(commit_id:, customer_id:, access_schedule: nil, applicable_product_ids: nil, applicable_product_tags: nil, hierarchy_configuration: nil, invoice_contract_id: nil, invoice_schedule: nil, priority: nil, product_id: nil, rate_type: nil, specifiers: nil, request_options: {})
230
232
  #
231
233
  # @param commit_id [String] ID of the commit to edit
232
234
  #
@@ -238,6 +240,8 @@ module MetronomeSDK
238
240
  #
239
241
  # @param applicable_product_tags [Array<String>, nil] Which tags the commit applies to. If applicable*product_ids, applicable_product*
240
242
  #
243
+ # @param hierarchy_configuration [MetronomeSDK::Models::CommitHierarchyConfiguration] Optional configuration for commit hierarchy access control
244
+ #
241
245
  # @param invoice_contract_id [String] ID of contract to use for invoicing
242
246
  #
243
247
  # @param invoice_schedule [MetronomeSDK::Models::V2::ContractEditCommitParams::InvoiceSchedule]
@@ -286,7 +290,7 @@ module MetronomeSDK
286
290
  # invoice. You can void the invoice beforehand and then remove the access
287
291
  # schedule segment.
288
292
  #
289
- # @overload edit_credit(credit_id:, customer_id:, access_schedule: nil, applicable_product_ids: nil, applicable_product_tags: nil, priority: nil, product_id: nil, rate_type: nil, specifiers: nil, request_options: {})
293
+ # @overload edit_credit(credit_id:, customer_id:, access_schedule: nil, applicable_product_ids: nil, applicable_product_tags: nil, hierarchy_configuration: nil, priority: nil, product_id: nil, rate_type: nil, specifiers: nil, request_options: {})
290
294
  #
291
295
  # @param credit_id [String] ID of the credit to edit
292
296
  #
@@ -298,6 +302,8 @@ module MetronomeSDK
298
302
  #
299
303
  # @param applicable_product_tags [Array<String>, nil] Which tags the credit applies to. If both applicable*product_ids and applicable*
300
304
  #
305
+ # @param hierarchy_configuration [MetronomeSDK::Models::CommitHierarchyConfiguration] Optional configuration for credit hierarchy access control
306
+ #
301
307
  # @param priority [Float, nil] If multiple commits are applicable, the one with the lower priority will apply f
302
308
  #
303
309
  # @param product_id [String]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MetronomeSDK
4
- VERSION = "1.0.0"
4
+ VERSION = "2.0.0"
5
5
  end
data/lib/metronome_sdk.rb CHANGED
@@ -221,6 +221,7 @@ require_relative "metronome_sdk/models/v1/customers/invoice_list_breakdowns_para
221
221
  require_relative "metronome_sdk/models/v1/customers/invoice_list_breakdowns_response"
222
222
  require_relative "metronome_sdk/models/v1/customers/invoice_list_params"
223
223
  require_relative "metronome_sdk/models/v1/customers/invoice_retrieve_params"
224
+ require_relative "metronome_sdk/models/v1/customers/invoice_retrieve_pdf_params"
224
225
  require_relative "metronome_sdk/models/v1/customers/invoice_retrieve_response"
225
226
  require_relative "metronome_sdk/models/v1/customers/named_schedule_retrieve_params"
226
227
  require_relative "metronome_sdk/models/v1/customers/named_schedule_retrieve_response"
@@ -250,6 +251,13 @@ require_relative "metronome_sdk/models/v1/invoice_regenerate_params"
250
251
  require_relative "metronome_sdk/models/v1/invoice_regenerate_response"
251
252
  require_relative "metronome_sdk/models/v1/invoice_void_params"
252
253
  require_relative "metronome_sdk/models/v1/invoice_void_response"
254
+ require_relative "metronome_sdk/models/v1/payment"
255
+ require_relative "metronome_sdk/models/v1/payment_attempt_params"
256
+ require_relative "metronome_sdk/models/v1/payment_attempt_response"
257
+ require_relative "metronome_sdk/models/v1/payment_cancel_params"
258
+ require_relative "metronome_sdk/models/v1/payment_cancel_response"
259
+ require_relative "metronome_sdk/models/v1/payment_list_params"
260
+ require_relative "metronome_sdk/models/v1/payment_status"
253
261
  require_relative "metronome_sdk/models/v1/plan_detail"
254
262
  require_relative "metronome_sdk/models/v1/plan_get_details_params"
255
263
  require_relative "metronome_sdk/models/v1/plan_get_details_response"
@@ -308,6 +316,7 @@ require_relative "metronome_sdk/resources/v1/customers/plans"
308
316
  require_relative "metronome_sdk/resources/v1/custom_fields"
309
317
  require_relative "metronome_sdk/resources/v1/dashboards"
310
318
  require_relative "metronome_sdk/resources/v1/invoices"
319
+ require_relative "metronome_sdk/resources/v1/payments"
311
320
  require_relative "metronome_sdk/resources/v1/plans"
312
321
  require_relative "metronome_sdk/resources/v1/pricing_units"
313
322
  require_relative "metronome_sdk/resources/v1/services"
@@ -33,6 +33,9 @@ module MetronomeSDK
33
33
  sig { returns(T.nilable(Integer)) }
34
34
  attr_accessor :status
35
35
 
36
+ sig { returns(T.nilable(T::Hash[String, String])) }
37
+ attr_accessor :headers
38
+
36
39
  sig { returns(T.nilable(T.anything)) }
37
40
  attr_accessor :body
38
41
 
@@ -41,6 +44,7 @@ module MetronomeSDK
41
44
  params(
42
45
  url: URI::Generic,
43
46
  status: T.nilable(Integer),
47
+ headers: T.nilable(T::Hash[String, String]),
44
48
  body: T.nilable(Object),
45
49
  request: NilClass,
46
50
  response: NilClass,
@@ -50,6 +54,7 @@ module MetronomeSDK
50
54
  def self.new(
51
55
  url:,
52
56
  status: nil,
57
+ headers: nil,
53
58
  body: nil,
54
59
  request: nil,
55
60
  response: nil,
@@ -70,6 +75,7 @@ module MetronomeSDK
70
75
  params(
71
76
  url: URI::Generic,
72
77
  status: NilClass,
78
+ headers: T.nilable(T::Hash[String, String]),
73
79
  body: NilClass,
74
80
  request: NilClass,
75
81
  response: NilClass,
@@ -79,6 +85,7 @@ module MetronomeSDK
79
85
  def self.new(
80
86
  url:,
81
87
  status: nil,
88
+ headers: nil,
82
89
  body: nil,
83
90
  request: nil,
84
91
  response: nil,
@@ -93,6 +100,7 @@ module MetronomeSDK
93
100
  params(
94
101
  url: URI::Generic,
95
102
  status: NilClass,
103
+ headers: T.nilable(T::Hash[String, String]),
96
104
  body: NilClass,
97
105
  request: NilClass,
98
106
  response: NilClass,
@@ -102,6 +110,7 @@ module MetronomeSDK
102
110
  def self.new(
103
111
  url:,
104
112
  status: nil,
113
+ headers: nil,
105
114
  body: nil,
106
115
  request: nil,
107
116
  response: nil,
@@ -116,13 +125,22 @@ module MetronomeSDK
116
125
  params(
117
126
  url: URI::Generic,
118
127
  status: Integer,
128
+ headers: T.nilable(T::Hash[String, String]),
119
129
  body: T.nilable(Object),
120
130
  request: NilClass,
121
131
  response: NilClass,
122
132
  message: T.nilable(String)
123
133
  ).returns(T.attached_class)
124
134
  end
125
- def self.for(url:, status:, body:, request:, response:, message: nil)
135
+ def self.for(
136
+ url:,
137
+ status:,
138
+ headers:,
139
+ body:,
140
+ request:,
141
+ response:,
142
+ message: nil
143
+ )
126
144
  end
127
145
 
128
146
  sig { returns(Integer) }
@@ -133,13 +151,22 @@ module MetronomeSDK
133
151
  params(
134
152
  url: URI::Generic,
135
153
  status: Integer,
154
+ headers: T.nilable(T::Hash[String, String]),
136
155
  body: T.nilable(Object),
137
156
  request: NilClass,
138
157
  response: NilClass,
139
158
  message: T.nilable(String)
140
159
  ).returns(T.attached_class)
141
160
  end
142
- def self.new(url:, status:, body:, request:, response:, message: nil)
161
+ def self.new(
162
+ url:,
163
+ status:,
164
+ headers:,
165
+ body:,
166
+ request:,
167
+ response:,
168
+ message: nil
169
+ )
143
170
  end
144
171
  end
145
172
 
@@ -27,7 +27,7 @@ module MetronomeSDK
27
27
  sig do
28
28
  params(
29
29
  content: T.any(Pathname, StringIO, IO, String),
30
- filename: T.nilable(String),
30
+ filename: T.nilable(T.any(Pathname, String)),
31
31
  content_type: T.nilable(String)
32
32
  ).returns(T.attached_class)
33
33
  end