Class: AdvancedBilling::SubscriptionNotesController

Inherits:
BaseController show all
Defined in:
lib/advanced_billing/controllers/subscription_notes_controller.rb

Overview

SubscriptionNotesController

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_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_subscription_note(subscription_id, body: nil) ⇒ SubscriptionNoteResponse

Creates a note for a subscription. Notes allow you to record information about a particular Subscription in a free text format. If you have structured data such as birth date, color, etc., consider using Metadata instead. For more information, see [Adding Notes](https://docs.maxio.com/hc/en-us/articles/24251654953997-Understandi ng-the-Subscription-Summary-Page#billing-portal-status:~:text=documentatio n%20for%20more.-,Adding%20Notes,-Notes%20are%20optional) in the product documentation. the subscription. description here

Parameters:

  • subscription_id (Integer)

    Required parameter: The Chargify id of

  • body (UpdateSubscriptionNoteRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/advanced_billing/controllers/subscription_notes_controller.rb', line 24

def create_subscription_note(subscription_id,
                             body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscriptions/{subscription_id}/notes.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(subscription_id, key: 'subscription_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(SubscriptionNoteResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end

#delete_subscription_note(subscription_id, note_id) ⇒ void

This method returns an undefined value.

Deletes a note for a Subscription. the subscription. the note

Parameters:

  • subscription_id (Integer)

    Required parameter: The Chargify id of

  • note_id (Integer)

    Required parameter: The Advanced Billing id of



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/advanced_billing/controllers/subscription_notes_controller.rb', line 155

def delete_subscription_note(subscription_id,
                             note_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/subscriptions/{subscription_id}/notes/{note_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(subscription_id, key: 'subscription_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(note_id, key: 'note_id')
                                .is_required(true)
                                .should_encode(true))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_response_void(true))
    .execute
end

#list_subscription_notes(options = {}) ⇒ Array[SubscriptionNoteResponse]

Retrieves a list of notes associated with a subscription. The response will be an array of Notes. the subscription. 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 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200. Use in query per_page=200.

Parameters:

  • subscription_id (Integer)

    Required parameter: The Chargify id of

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/advanced_billing/controllers/subscription_notes_controller.rb', line 64

def list_subscription_notes(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/subscriptions/{subscription_id}/notes.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(options['subscription_id'], key: 'subscription_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'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionNoteResponse.method(:from_hash))
                .is_response_array(true)
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end

#read_subscription_note(subscription_id, note_id) ⇒ SubscriptionNoteResponse

Retrieves a specific note attached to a subscription. the subscription. the note

Parameters:

  • subscription_id (Integer)

    Required parameter: The Chargify id of

  • note_id (Integer)

    Required parameter: The Advanced Billing id of

Returns:



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/advanced_billing/controllers/subscription_notes_controller.rb', line 93

def read_subscription_note(subscription_id,
                           note_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/subscriptions/{subscription_id}/notes/{note_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(subscription_id, key: 'subscription_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(note_id, key: 'note_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionNoteResponse.method(:from_hash)))
    .execute
end

#update_subscription_note(subscription_id, note_id, body: nil) ⇒ SubscriptionNoteResponse

Updates a note for a subscription. the subscription. the note description here

Parameters:

  • subscription_id (Integer)

    Required parameter: The Chargify id of

  • note_id (Integer)

    Required parameter: The Advanced Billing id of

  • body (UpdateSubscriptionNoteRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



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

def update_subscription_note(subscription_id,
                             note_id,
                             body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/subscriptions/{subscription_id}/notes/{note_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(subscription_id, key: 'subscription_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(note_id, key: 'note_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(SubscriptionNoteResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end