Class: Printful::VariantsResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/printful/resources/variants.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Printful::Resource

Instance Method Details

#create(id:, **params) ⇒ Object



4
5
6
7
8
# File 'lib/printful/resources/variants.rb', line 4

def create(id:, **params)
  # attributes = {sync_product: product, sync_variants: variants}
  response = post_request("store/products/#{id}/variants", body: params)
  Variant.new(response.body["result"])
end

#delete(id:) ⇒ Object



20
21
22
23
# File 'lib/printful/resources/variants.rb', line 20

def delete(id:)
  response = delete_request("store/variants/#{id}")
  return true if response.success?
end

#retrieve(id:) ⇒ Object



10
11
12
13
# File 'lib/printful/resources/variants.rb', line 10

def retrieve(id:)
  response = get_request("store/variants/#{id}")
  Variant.new(response.body["result"])
end

#update(id:, **params) ⇒ Object



15
16
17
18
# File 'lib/printful/resources/variants.rb', line 15

def update(id:, **params)
  response = put_request("store/variants/#{id}", body: params)
  return true if response.success?
end