Class: AdvancedBilling::EventsBasedBillingSegmentsController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/advanced_billing/controllers/events_based_billing_segments_controller.rb

Overview

EventsBasedBillingSegmentsController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from AdvancedBilling::BaseController

Instance Method Details

#create_segment(component_id, price_point_id, body: nil) ⇒ SegmentResponse

This endpoint creates a new Segment for a Component with segmented Metric. It allows you to specify properties to bill upon and prices for each Segment. You can only pass as many “property_values” as the related Metric has segmenting properties defined. You may specify component and/or price point by using either the numeric ID or the ‘handle:gold` syntax. Component Price Point belonging to the Component

Parameters:

  • component_id (String)

    Required parameter: ID or Handle for the

  • price_point_id (String)

    Required parameter: ID or Handle for the

  • body (CreateSegmentRequest) (defaults to: nil)

    Optional parameter: Example:

Returns:



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
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 21

def create_segment(component_id,
                   price_point_id,
                   body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/components/{component_id}/price_points/{price_point_id}/segments.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SegmentResponse.method(:from_hash))
                .local_error('401',
                             'Unauthorized',
                             APIException)
                .local_error('403',
                             'Forbidden',
                             APIException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             EventBasedBillingSegmentErrorsException))
    .execute
end

#create_segments(component_id, price_point_id, body: nil) ⇒ ListSegmentsResponse

This endpoint allows you to create multiple segments in one request. The array of segments can contain up to ‘2000` records. If any of the records contain an error the whole request would fail and none of the requested segments get created. The error response contains a message for only the one segment that failed validation, with the corresponding index in the array. You may specify component and/or price point by using either the numeric ID or the `handle:gold` syntax. Component Price Point belonging to the Component

Parameters:

  • component_id (String)

    Required parameter: ID or Handle for the

  • price_point_id (String)

    Required parameter: ID or Handle for the

  • body (BulkCreateSegments) (defaults to: nil)

    Optional parameter: Example:

Returns:



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 219

def create_segments(component_id,
                    price_point_id,
                    body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/components/{component_id}/price_points/{price_point_id}/segments/bulk.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ListSegmentsResponse.method(:from_hash))
                .local_error('401',
                             'Unauthorized',
                             APIException)
                .local_error('403',
                             'Forbidden',
                             APIException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             EventBasedBillingSegmentException))
    .execute
end

#delete_segment(component_id, price_point_id, id) ⇒ void

This method returns an undefined value.

This endpoint allows you to delete a Segment with specified ID. You may specify component and/or price point by using either the numeric ID or the ‘handle:gold` syntax. Component Price Point belonging to the Component

Parameters:

  • component_id (String)

    Required parameter: ID or Handle of the

  • price_point_id (String)

    Required parameter: ID or Handle of the

  • id (Float)

    Required parameter: The ID of the Segment



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 170

def delete_segment(component_id,
                   price_point_id,
                   id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/components/{component_id}/price_points/{price_point_id}/segments/{id}.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_nullify404(true)
                .is_response_void(true)
                .local_error('401',
                             'Unauthorized',
                             APIException)
                .local_error('403',
                             'Forbidden',
                             APIException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             APIException))
    .execute
end

#list_segments_for_price_point(options = {}) ⇒ ListSegmentsResponse

This endpoint allows you to fetch Segments created for a given Price Point. They will be returned in the order of creation. You can pass ‘page` and `per_page` parameters in order to access all of the segments. By default it will return `30` records. You can set `per_page` to `200` at most. You may specify component and/or price point by using either the numeric ID or the `handle:gold` syntax. Component Price Point belonging to the Component pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned. Use in query `page=1`. many records to fetch in each request. Default value is 30. The maximum allowed values is 200; any per_page value over 200 will be changed to 200. Use in query `per_page=200`. value passed here would be used to filter segments. Pass a value related to `segment_property_1` on attached Metric. If empty string is passed, this filter would be rejected. Use in query `filter=EU`. value passed here would be used to filter segments. Pass a value related to `segment_property_2` on attached Metric. If empty string is passed, this filter would be rejected. value passed here would be used to filter segments. Pass a value related to `segment_property_3` on attached Metric. If empty string is passed, this filter would be rejected. value passed here would be used to filter segments. Pass a value related to `segment_property_4` on attached Metric. If empty string is passed, this filter would be rejected.

Parameters:

  • component_id (String)

    Required parameter: ID or Handle for the

  • price_point_id (String)

    Required parameter: ID or Handle for the

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • filter_segment_property_1_value (String)

    Optional parameter: The

  • filter_segment_property_2_value (String)

    Optional parameter: The

  • filter_segment_property_3_value (String)

    Optional parameter: The

  • filter_segment_property_4_value (String)

    Optional parameter: The

Returns:



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 296

def list_segments_for_price_point(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/components/{component_id}/price_points/{price_point_id}/segments.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['component_id'], key: 'component_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(options['price_point_id'], key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .query_param(new_parameter(options['filter_segment_property_1_value'], key: 'filter[segment_property_1_value]'))
               .query_param(new_parameter(options['filter_segment_property_2_value'], key: 'filter[segment_property_2_value]'))
               .query_param(new_parameter(options['filter_segment_property_3_value'], key: 'filter[segment_property_3_value]'))
               .query_param(new_parameter(options['filter_segment_property_4_value'], key: 'filter[segment_property_4_value]'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ListSegmentsResponse.method(:from_hash))
                .local_error('401',
                             'Unauthorized',
                             APIException)
                .local_error('403',
                             'Forbidden',
                             APIException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             EventBasedBillingListSegmentsErrorsException))
    .execute
end

#update_segment(component_id, price_point_id, id, body: nil) ⇒ SegmentResponse

This endpoint updates a single Segment for a Component with a segmented Metric. It allows you to update the pricing for the segment. You may specify component and/or price point by using either the numeric ID or the ‘handle:gold` syntax. Component Price Point belonging to the Component

Parameters:

  • component_id (String)

    Required parameter: ID or Handle of the

  • price_point_id (String)

    Required parameter: ID or Handle of the

  • id (Float)

    Required parameter: The ID of the Segment

  • body (UpdateSegmentRequest) (defaults to: nil)

    Optional parameter: Example:

Returns:



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 120

def update_segment(component_id,
                   price_point_id,
                   id,
                   body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/components/{component_id}/price_points/{price_point_id}/segments/{id}.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SegmentResponse.method(:from_hash))
                .local_error('401',
                             'Unauthorized',
                             APIException)
                .local_error('403',
                             'Forbidden',
                             APIException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             EventBasedBillingSegmentErrorsException))
    .execute
end

#update_segments(component_id, price_point_id, body: nil) ⇒ ListSegmentsResponse

This endpoint allows you to update multiple segments in one request. The array of segments can contain up to ‘1000` records. If any of the records contain an error the whole request would fail and none of the requested segments get updated. The error response contains a message for only the one segment that failed validation, with the corresponding index in the array. You may specify component and/or price point by using either the numeric ID or the `handle:gold` syntax. Component Price Point belonging to the Component

Parameters:

  • component_id (String)

    Required parameter: ID or Handle for the

  • price_point_id (String)

    Required parameter: ID or Handle for the

  • body (BulkUpdateSegments) (defaults to: nil)

    Optional parameter: Example:

Returns:



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
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 72

def update_segments(component_id,
                    price_point_id,
                    body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/components/{component_id}/price_points/{price_point_id}/segments/bulk.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ListSegmentsResponse.method(:from_hash))
                .local_error('401',
                             'Unauthorized',
                             APIException)
                .local_error('403',
                             'Forbidden',
                             APIException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             EventBasedBillingSegmentException))
    .execute
end