class CanadaPost::Request::Registration
Public Class Methods
new(credentials)
click to toggle source
Calls superclass method
CanadaPost::Request::Base::new
# File lib/canada_post/request/registration.rb, line 5 def initialize(credentials) @credentials = credentials super(credentials) end
Public Instance Methods
get_token()
click to toggle source
# File lib/canada_post/request/registration.rb, line 10 def get_token api_response = self.class.post( api_url, headers: api_header, basic_auth: @authorization ) shipping_response = process_response(api_response) if shipping_response[:token].present? shipping_response[:token] else shipping_response end end
merchant_info(token)
click to toggle source
# File lib/canada_post/request/registration.rb, line 24 def merchant_info(token) merchant_url = api_url + "/#{token}" api_response = self.class.get( merchant_url, headers: api_header, basic_auth: @authorization ) process_response(api_response) end
Private Instance Methods
api_header()
click to toggle source
# File lib/canada_post/request/registration.rb, line 36 def api_header { 'Accept-Language' => 'en-CA', 'Accept' => 'application/vnd.cpc.registration+xml' } end
api_url()
click to toggle source
# File lib/canada_post/request/registration.rb, line 43 def api_url api_url = @credentials.mode == "production" ? PRODUCTION_URL : TEST_URL api_url += "/ot/token" end