Class: Gumroad::Product

Inherits:
Object
  • Object
show all
Defined in:
lib/gumroad/product.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Product

Returns a new instance of Product.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/gumroad/product.rb', line 32

def initialize(attributes)
  @id                    = attributes['id']
  @custom_receipt        = attributes['custom_receipt']
  @custom_summary        = attributes['custom_summary']
  @custom_fields         = attributes['custom_fields']
  @customizable_price    = attributes['customizable_price']
  @deleted               = attributes['deleted']
  @max_purchase_count    = attributes['max_purchase_count']
  @name                  = attributes['name']
  @require_shipping      = attributes['require_shipping']
  @subscription_duration = attributes['subscription_duration']
  @custom_permalink      = attributes['custom_permalink']
  @published             = attributes['published']
  @url                   = attributes['url']
  @webhook               = attributes['webhook']
  @price                 = attributes['price']
  @custom_product_type   = attributes['custom_product_type']
  @countries_available   = attributes['countries_available']
  @short_url             = attributes['short_url']
  @formatted_price       = attributes['formatted_price']
  @description           = attributes['description']
  @preview_url           = attributes['preview_url']
  @file_info             = attributes['file_info'] 
  @shown_on_profile      = attributes['shown_on_profile']
  @view_count            = attributes['view_count']
  @sales_count           = attributes['sales_count']
  @sales_usd_cents       = attributes['sales_usd_cents']
end

Instance Attribute Details

#countries_availableObject

Returns the value of attribute countries_available.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def countries_available
  @countries_available
end

Returns the value of attribute custom_permalink.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def custom_permalink
  @custom_permalink
end

#custom_reciptObject

Returns the value of attribute custom_recipt.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def custom_recipt
  @custom_recipt
end

#custom_summaryObject

Returns the value of attribute custom_summary.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def custom_summary
  @custom_summary
end

#customizable_priceObject

Returns the value of attribute customizable_price.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def customizable_price
  @customizable_price
end

#deletedObject (readonly)

Returns the value of attribute deleted.



8
9
10
# File 'lib/gumroad/product.rb', line 8

def deleted
  @deleted
end

#descriptionObject

Returns the value of attribute description.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def description
  @description
end

#fileObject

Returns the value of attribute file.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def file
  @file
end

#formatted_priceObject (readonly)

Returns the value of attribute formatted_price.



8
9
10
# File 'lib/gumroad/product.rb', line 8

def formatted_price
  @formatted_price
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/gumroad/product.rb', line 8

def id
  @id
end

#is_recurring_billingObject

Returns the value of attribute is_recurring_billing.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def is_recurring_billing
  @is_recurring_billing
end

#max_purchase_countObject

Returns the value of attribute max_purchase_count.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def max_purchase_count
  @max_purchase_count
end

#nameObject

Returns the value of attribute name.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def name
  @name
end

#preview_urlObject

Returns the value of attribute preview_url.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def preview_url
  @preview_url
end

#priceObject

Returns the value of attribute price.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def price
  @price
end

#require_shippingObject

Returns the value of attribute require_shipping.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def require_shipping
  @require_shipping
end

#sales_countObject (readonly)

Returns the value of attribute sales_count.



8
9
10
# File 'lib/gumroad/product.rb', line 8

def sales_count
  @sales_count
end

#sales_usd_centsObject (readonly)

Returns the value of attribute sales_usd_cents.



8
9
10
# File 'lib/gumroad/product.rb', line 8

def sales_usd_cents
  @sales_usd_cents
end

#shown_on_profileObject

Returns the value of attribute shown_on_profile.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def shown_on_profile
  @shown_on_profile
end

#subscription_durationObject

Returns the value of attribute subscription_duration.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def subscription_duration
  @subscription_duration
end

#view_countObject (readonly)

Returns the value of attribute view_count.



8
9
10
# File 'lib/gumroad/product.rb', line 8

def view_count
  @view_count
end

#webhookObject

Returns the value of attribute webhook.



15
16
17
# File 'lib/gumroad/product.rb', line 15

def webhook
  @webhook
end

Class Method Details

.allObject



104
105
106
107
108
# File 'lib/gumroad/product.rb', line 104

def self.all
  response = Faraday.get("#{API_ROOT}", {'access_token' => Gumroad.get_token})
  data = JSON.parse(response.body)
  data['products'].map { |attributes| new(attributes)  }
end

.create(file, data) ⇒ Object



97
98
99
100
101
102
# File 'lib/gumroad/product.rb', line 97

def self.create(file, data)
  data['access_token'] = Gumroad.get_token
  response = Faraday.post("#{API_ROOT}", data)
  data = JSON.parse(response.body)
  new(data['product'])
end

.find(id) ⇒ Object



110
111
112
113
114
# File 'lib/gumroad/product.rb', line 110

def self.find(id)
  response = Faraday.get("#{API_ROOT}/#{id}", {'access_token' => Gumroad.get_token})
  data = JSON.parse(response.body)
  new(data['product'])
end

Instance Method Details

#create_custom_fieldObject



94
95
# File 'lib/gumroad/product.rb', line 94

def create_custom_field
end

#create_offer_code(data) ⇒ Object



79
80
# File 'lib/gumroad/product.rb', line 79

def create_offer_code(data)
end

#create_variantObject



85
86
# File 'lib/gumroad/product.rb', line 85

def create_variant
end

#custom_field(id) ⇒ Object



91
92
# File 'lib/gumroad/product.rb', line 91

def custom_field(id)
end

#custom_fieldsObject



88
89
# File 'lib/gumroad/product.rb', line 88

def custom_fields
end

#deleteObject



67
68
69
70
71
# File 'lib/gumroad/product.rb', line 67

def delete
  data = { access_token: Gumroad.get_token }
  response = Faraday.delete("#{API_ROOT}/#{@id}", data)
  JSON.parse(response.body)
end

#offer_codeObject



76
77
# File 'lib/gumroad/product.rb', line 76

def offer_code
end

#offer_codesObject



73
74
# File 'lib/gumroad/product.rb', line 73

def offer_codes
end

#saveObject



61
62
63
64
65
# File 'lib/gumroad/product.rb', line 61

def save
  response = Faraday.put("#{API_ROOT}/#{@id}", serialize)
  data = JSON.parse(response.body)
  new(data['product'])
end

#variantObject



82
83
# File 'lib/gumroad/product.rb', line 82

def variant
end