Module: ShopifyClient::Resource::Create

Defined in:
lib/shopify-client/resource/create.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Parameters:

  • base (Class)


7
8
9
# File 'lib/shopify-client/resource/create.rb', line 7

def self.included(base)
  base.include(Base)
end

Instance Method Details

#create(client, data) ⇒ Integer

Returns the new result.id.

Parameters:

Returns:

  • (Integer)

    the new result.id



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/shopify-client/resource/create.rb', line 15

def create(client, data)
  result = client.post(resource_name, resource_name_singular => data).data[resource_name_singular]

  result['id'].tap do |id|
    ShopifyClient.config.logger({
      source: 'shopify-client',
      type: 'create',
      info: {
        resource: resource_name,
        id: id,
      },
    }.to_json)
  end
end