Class: MasonHubAPI::ReturnResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/mason_hub_api/resources/return.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#delete_request, #get_request, #initialize, #post_request, #put_request

Constructor Details

This class inherits a constructor from MasonHubAPI::Resource

Instance Method Details

#all(attributes = {}) ⇒ Object



12
13
14
15
16
17
# File 'lib/mason_hub_api/resources/return.rb', line 12

def all(attributes = {})
  response = Response.new(get_request("rmas", params: attributes).body)
  response.data = response.data.map { |rma| Return.new(rma) }

  response
end

#create(attributes) ⇒ Object



5
6
7
8
9
10
# File 'lib/mason_hub_api/resources/return.rb', line 5

def create(attributes)
  # accept either a single hash or an array of hashes
  attributes = [attributes] if attributes.is_a?(Hash)

  Response.new(post_request("rmas", body: attributes).body)
end

#delete(customer_identifiers) ⇒ Object



26
27
28
29
30
31
# File 'lib/mason_hub_api/resources/return.rb', line 26

def delete(customer_identifiers)
  customer_identifiers = [customer_identifiers] if customer_identifiers.is_a?(String)
  customer_identifiers = customer_identifiers.map { |customer_identifier| { customer_identifier: customer_identifier } }
  
  Response.new(delete_request("rmas", body: customer_identifiers).body)
end

#update(attributes) ⇒ Object



19
20
21
22
23
24
# File 'lib/mason_hub_api/resources/return.rb', line 19

def update(attributes)
  # accept either a single hash or an array of hashes
  attributes = [attributes] if attributes.is_a?(Hash)

  Response.new(put_request("rmas", body: attributes).body)
end