Class: AdvancedBilling::ReferralCodesController

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

Overview

ReferralCodesController

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

#validate_referral_code(code) ⇒ ReferralValidationResponse

Use this method to determine if the referral code is valid and applicable within your Site. This method is useful for validating referral codes that are entered by a customer. ## Referrals Documentation Full documentation on how to use the referrals feature in the Advanced Billing UI can be located [here](maxio.zendesk.com/hc/en-us/sections/24286965611405-Referral s). ## Server Response If the referral code is valid the status code will be ‘200` and the referral code will be returned. If the referral code is invalid, a `404` response will be returned. to validate

Parameters:

  • code (String)

    Required parameter: The referral code you are trying

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/advanced_billing/controllers/referral_codes_controller.rb', line 24

def validate_referral_code(code)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/referral_codes/validate.json',
                                 Server::DEFAULT)
               .query_param(new_parameter(code, key: 'code')
                             .is_required(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(ReferralValidationResponse.method(:from_hash))
                .local_error_template('404',
                                      'Invalid referral code.',
                                      SingleStringErrorResponseException))
    .execute
end