Class: Shipvine::ItemGroup

Inherits:
Base
  • Object
show all
Defined in:
lib/shipvine/item_group.rb

Constant Summary

Constants inherited from Base

Base::WAREHOUSE_XSD_FILE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

client, xml_to_hash

Constructor Details

#initialize(attributes) ⇒ ItemGroup

Returns a new instance of ItemGroup.



22
23
24
# File 'lib/shipvine/item_group.rb', line 22

def initialize(attributes)
  @attributes = attributes
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



20
21
22
# File 'lib/shipvine/item_group.rb', line 20

def attributes
  @attributes
end

Class Method Details

.get(item_merchant_identifier) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/shipvine/item_group.rb', line 4

def self.get(item_merchant_identifier)
  request = self.client.request(
    :get,

    # TODO escape SKU?

    '/item-groups/' +
      Shipvine.merchant_code + '/' +
      item_merchant_identifier
  )

  self.new(self.xml_to_hash(request.body))
rescue Shipvine::Error => e
  nil
end

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/shipvine/item_group.rb', line 26

def create
  translated_payload = @attributes.deep_dup

  merchant_identifier = translated_payload.delete(:merchant_identifier)

  client.request(
    :put,
    '/item-groups/' +
      Shipvine.merchant_code + '/' + merchant_identifier,
    request_body('ItemGroup', translated_payload)
  )
end