Class: Gumroad::Product
- Inherits:
-
Object
- Object
- Gumroad::Product
- Defined in:
- lib/gumroad/product.rb
Instance Attribute Summary collapse
-
#countries_available ⇒ Object
Returns the value of attribute countries_available.
-
#custom_permalink ⇒ Object
Returns the value of attribute custom_permalink.
-
#custom_recipt ⇒ Object
Returns the value of attribute custom_recipt.
-
#custom_summary ⇒ Object
Returns the value of attribute custom_summary.
-
#customizable_price ⇒ Object
Returns the value of attribute customizable_price.
-
#deleted ⇒ Object
readonly
Returns the value of attribute deleted.
-
#description ⇒ Object
Returns the value of attribute description.
-
#file ⇒ Object
Returns the value of attribute file.
-
#formatted_price ⇒ Object
readonly
Returns the value of attribute formatted_price.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_recurring_billing ⇒ Object
Returns the value of attribute is_recurring_billing.
-
#max_purchase_count ⇒ Object
Returns the value of attribute max_purchase_count.
-
#name ⇒ Object
Returns the value of attribute name.
-
#preview_url ⇒ Object
Returns the value of attribute preview_url.
-
#price ⇒ Object
Returns the value of attribute price.
-
#require_shipping ⇒ Object
Returns the value of attribute require_shipping.
-
#sales_count ⇒ Object
readonly
Returns the value of attribute sales_count.
-
#sales_usd_cents ⇒ Object
readonly
Returns the value of attribute sales_usd_cents.
-
#shown_on_profile ⇒ Object
Returns the value of attribute shown_on_profile.
-
#subscription_duration ⇒ Object
Returns the value of attribute subscription_duration.
-
#view_count ⇒ Object
readonly
Returns the value of attribute view_count.
-
#webhook ⇒ Object
Returns the value of attribute webhook.
Class Method Summary collapse
Instance Method Summary collapse
- #create_custom_field ⇒ Object
- #create_offer_code(data) ⇒ Object
- #create_variant ⇒ Object
- #custom_field(id) ⇒ Object
- #custom_fields ⇒ Object
- #delete ⇒ Object
-
#initialize(attributes) ⇒ Product
constructor
A new instance of Product.
- #offer_code ⇒ Object
- #offer_codes ⇒ Object
- #save ⇒ Object
- #variant ⇒ Object
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_available ⇒ Object
Returns the value of attribute countries_available.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def countries_available @countries_available end |
#custom_permalink ⇒ Object
Returns the value of attribute custom_permalink.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def custom_permalink @custom_permalink end |
#custom_recipt ⇒ Object
Returns the value of attribute custom_recipt.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def custom_recipt @custom_recipt end |
#custom_summary ⇒ Object
Returns the value of attribute custom_summary.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def custom_summary @custom_summary end |
#customizable_price ⇒ Object
Returns the value of attribute customizable_price.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def customizable_price @customizable_price end |
#deleted ⇒ Object (readonly)
Returns the value of attribute deleted.
8 9 10 |
# File 'lib/gumroad/product.rb', line 8 def deleted @deleted end |
#description ⇒ Object
Returns the value of attribute description.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def description @description end |
#file ⇒ Object
Returns the value of attribute file.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def file @file end |
#formatted_price ⇒ Object (readonly)
Returns the value of attribute formatted_price.
8 9 10 |
# File 'lib/gumroad/product.rb', line 8 def formatted_price @formatted_price end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/gumroad/product.rb', line 8 def id @id end |
#is_recurring_billing ⇒ Object
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_count ⇒ Object
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 |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def name @name end |
#preview_url ⇒ Object
Returns the value of attribute preview_url.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def preview_url @preview_url end |
#price ⇒ Object
Returns the value of attribute price.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def price @price end |
#require_shipping ⇒ Object
Returns the value of attribute require_shipping.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def require_shipping @require_shipping end |
#sales_count ⇒ Object (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_cents ⇒ Object (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_profile ⇒ Object
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_duration ⇒ Object
Returns the value of attribute subscription_duration.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def subscription_duration @subscription_duration end |
#view_count ⇒ Object (readonly)
Returns the value of attribute view_count.
8 9 10 |
# File 'lib/gumroad/product.rb', line 8 def view_count @view_count end |
#webhook ⇒ Object
Returns the value of attribute webhook.
15 16 17 |
# File 'lib/gumroad/product.rb', line 15 def webhook @webhook end |
Class Method Details
.all ⇒ Object
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 |
Instance Method Details
#create_custom_field ⇒ Object
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_variant ⇒ Object
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_fields ⇒ Object
88 89 |
# File 'lib/gumroad/product.rb', line 88 def custom_fields end |
#delete ⇒ Object
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_code ⇒ Object
76 77 |
# File 'lib/gumroad/product.rb', line 76 def offer_code end |
#offer_codes ⇒ Object
73 74 |
# File 'lib/gumroad/product.rb', line 73 def offer_codes end |
#save ⇒ Object
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 |
#variant ⇒ Object
82 83 |
# File 'lib/gumroad/product.rb', line 82 def variant end |