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

Use the following method to create a note for a subscription. ## How to Use Subscription Notes 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. Full documentation on how to use Notes in the Chargify UI can be located [here](maxio-chargify.zendesk.com/hc/en-us/articles/5404434903181- Subscription-Summary#notes). subscription

Parameters:

  • subscription_id (String)

    Required parameter: The Chargify id of the

  • body (UpdateSubscriptionNoteRequest) (defaults to: nil)

    Optional parameter: Example:

Returns:



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/advanced_billing/controllers/subscription_notes_controller.rb', line 138

def create_subscription_note(subscription_id,
                             body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscriptions/{subscription_id}/notes.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionNoteResponse.method(:from_hash)))
    .execute
end

#delete_subscription_note(subscription_id) ⇒ void

This method returns an undefined value.

Use the following method to delete a note for a Subscription. subscription

Parameters:

  • subscription_id (String)

    Required parameter: The Chargify id of the



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/advanced_billing/controllers/subscription_notes_controller.rb', line 44

def delete_subscription_note(subscription_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/subscriptions/{subscription_id}/notes.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(subscription_id, key: 'subscription_id')
                                .is_required(true)
                                .should_encode(true))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_nullify404(true)
                .is_response_void(true)
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             APIException))
    .execute
end

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

Use this method to retrieve a list of Notes associated with a Subscription. The response will be an array of Notes. 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 (String)

    Required parameter: The Chargify id of the

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

Returns:



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/advanced_billing/controllers/subscription_notes_controller.rb', line 78

def list_subscription_notes(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/subscriptions/{subscription_id}/notes.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionNoteResponse.method(:from_hash))
                .is_response_array(true))
    .execute
end

#read_subscription_note(subscription_id, note_id) ⇒ SubscriptionNoteResponse

Once you have obtained the ID of the note you wish to read, use this method to show a particular note attached to a subscription. subscription

Parameters:

  • subscription_id (String)

    Required parameter: The Chargify id of the

  • note_id (String)

    Required parameter: The Chargify id of the note

Returns:



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/advanced_billing/controllers/subscription_notes_controller.rb', line 104

def read_subscription_note(subscription_id,
                           note_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/subscriptions/{subscription_id}/notes/{note_id}.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionNoteResponse.method(:from_hash)))
    .execute
end

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

Use the following method to update a note for a Subscription. subscription

Parameters:

  • subscription_id (String)

    Required parameter: The Chargify id of the

  • note_id (String)

    Required parameter: The Chargify id of the note

  • body (UpdateSubscriptionNoteRequest) (defaults to: nil)

    Optional parameter: Example:

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/advanced_billing/controllers/subscription_notes_controller.rb', line 15

def update_subscription_note(subscription_id,
                             note_id,
                             body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/subscriptions/{subscription_id}/notes/{note_id}.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionNoteResponse.method(:from_hash)))
    .execute
end