Class: AdvancedBilling::EventsBasedBillingSegmentsController
- Inherits:
-
BaseController
- Object
- BaseController
- AdvancedBilling::EventsBasedBillingSegmentsController
- Defined in:
- lib/advanced_billing/controllers/events_based_billing_segments_controller.rb
Overview
EventsBasedBillingSegmentsController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#bulk_create_segments(component_id, price_point_id, body: nil) ⇒ ListSegmentsResponse
Creates multiple segments in one request.
-
#bulk_update_segments(component_id, price_point_id, body: nil) ⇒ ListSegmentsResponse
Updates multiple segments in one request.
-
#create_segment(component_id, price_point_id, body: nil) ⇒ SegmentResponse
Creates a new segment for a component with a segmented metric.
-
#delete_segment(component_id, price_point_id, id) ⇒ void
Deletes a segment with the specified ID.
-
#list_segments_for_price_point(options = {}) ⇒ ListSegmentsResponse
Lists segments created for a given price point, in order of creation.
-
#update_segment(component_id, price_point_id, id, body: nil) ⇒ SegmentResponse
Updates a single segment for a component with a segmented metric.
Methods inherited from BaseController
#initialize, #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
#bulk_create_segments(component_id, price_point_id, body: nil) ⇒ ListSegmentsResponse
Creates 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 description here
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 207 def bulk_create_segments(component_id, price_point_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/components/{component_id}/price_points/{price_point_id}/segments/bulk.json', Server::PRODUCTION) .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 .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ListSegmentsResponse.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', EventBasedBillingSegmentException)) .execute end |
#bulk_update_segments(component_id, price_point_id, body: nil) ⇒ ListSegmentsResponse
Updates 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 description here
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 253 def bulk_update_segments(component_id, price_point_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/components/{component_id}/price_points/{price_point_id}/segments/bulk.json', Server::PRODUCTION) .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 .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ListSegmentsResponse.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', EventBasedBillingSegmentException)) .execute end |
#create_segment(component_id, price_point_id, body: nil) ⇒ SegmentResponse
Creates a new segment for a component with a 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 description here
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 |
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 22 def create_segment(component_id, price_point_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/components/{component_id}/price_points/{price_point_id}/segments.json', Server::PRODUCTION) .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 .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(SegmentResponse.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', EventBasedBillingSegmentErrorsException)) .execute end |
#delete_segment(component_id, price_point_id, id) ⇒ void
This method returns an undefined value.
Deletes a segment with the 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
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 163 def delete_segment(component_id, price_point_id, id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/components/{component_id}/price_points/{price_point_id}/segments/{id}.json', Server::PRODUCTION) .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_response_void(true) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', APIException)) .execute end |
#list_segments_for_price_point(options = {}) ⇒ ListSegmentsResponse
Lists segments created for a given price point, in 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`. List Segments for a Price Point operation
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 |
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 77 def list_segments_for_price_point( = {}) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/components/{component_id}/price_points/{price_point_id}/segments.json', Server::PRODUCTION) .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)) .query_param(new_parameter(['page'], key: 'page')) .query_param(new_parameter(['per_page'], key: 'per_page')) .query_param(new_parameter(['filter'], key: 'filter')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth')) .array_serialization_format(ArraySerializationFormat::CSV)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ListSegmentsResponse.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', EventBasedBillingListSegmentsErrorsException)) .execute end |
#update_segment(component_id, price_point_id, id, body: nil) ⇒ SegmentResponse
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 description here
119 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 |
# File 'lib/advanced_billing/controllers/events_based_billing_segments_controller.rb', line 119 def update_segment(component_id, price_point_id, id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/components/{component_id}/price_points/{price_point_id}/segments/{id}.json', Server::PRODUCTION) .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 .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(SegmentResponse.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', EventBasedBillingSegmentErrorsException)) .execute end |