Class: CanadaPost::Request::Manifest

Inherits:
Base
  • Object
show all
Defined in:
lib/canada_post/request/manifest.rb

Constant Summary

Constants inherited from Base

Base::OPTION_CODES, Base::PRODUCTION_URL, Base::SERVICE_CODES, Base::TEST_CONTRACT_ID, Base::TEST_URL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#client, #parse_response, #process_response, #sanitize_response_keys

Constructor Details

#initialize(credentials, options = {}) ⇒ Manifest

Returns a new instance of Manifest.



7
8
9
10
11
12
13
14
15
# File 'lib/canada_post/request/manifest.rb', line 7

def initialize(credentials, options={})
  @credentials = credentials
  if options.present?
    @phone = options[:phone]
    @destination = options[:destination]
    @group_id = options[:group_id]
  end
  super(credentials)
end

Instance Attribute Details

#destinationObject

Returns the value of attribute destination.



5
6
7
# File 'lib/canada_post/request/manifest.rb', line 5

def destination
  @destination
end

#group_idObject

Returns the value of attribute group_id.



5
6
7
# File 'lib/canada_post/request/manifest.rb', line 5

def group_id
  @group_id
end

#phoneObject

Returns the value of attribute phone.



5
6
7
# File 'lib/canada_post/request/manifest.rb', line 5

def phone
  @phone
end

Instance Method Details

#get_artifact(url) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/canada_post/request/manifest.rb', line 36

def get_artifact(url)
  self.class.get(
    url,
    headers: artifact_header,
    basic_auth: @authorization
  )
end

#get_manifest(url) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/canada_post/request/manifest.rb', line 27

def get_manifest(url)
  api_response = self.class.get(
    url,
    headers: manifest_header,
    basic_auth: @authorization
  )
  process_response(api_response)
end

#process_requestObject



17
18
19
20
21
22
23
24
25
# File 'lib/canada_post/request/manifest.rb', line 17

def process_request
  api_response = self.class.post(
    api_url,
    body: build_xml,
    headers: manifest_header,
    basic_auth: @authorization
  )
  process_response(api_response)
end