Class: AnPostReturn::Resources::ReturnLabelResource
- Inherits:
-
Object
- Object
- AnPostReturn::Resources::ReturnLabelResource
- Defined in:
- lib/an_post_return/resources/return_label_resource.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#create(params) ⇒ AReturnLabel
Create a return label.
-
#initialize(client) ⇒ ReturnLabelResource
constructor
A new instance of ReturnLabelResource.
Constructor Details
#initialize(client) ⇒ ReturnLabelResource
Returns a new instance of ReturnLabelResource.
7 8 9 |
# File 'lib/an_post_return/resources/return_label_resource.rb', line 7 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/an_post_return/resources/return_label_resource.rb', line 5 def client @client end |
Instance Method Details
#create(params) ⇒ AReturnLabel
Create a return label
113 114 115 116 117 118 119 120 |
# File 'lib/an_post_return/resources/return_label_resource.rb', line 113 def create(params) raise ArgumentError, "Missing required parameters" if params.nil? raise ArgumentError, "Subscription key not configured" if client.config.subscription_key.nil? response = client.connection.post("returnsLabel") { |req| req.body = params } response_data = client.send(:handle_response, response) ReturnLabel.new(response_data) end |