class Gumrider
Attributes
endpoint[RW]
token[RW]
Public Class Methods
new(email, password)
click to toggle source
# File lib/gumrider.rb, line 9 def initialize(email, password) @email = email @password = password @endpoint = 'https://gumroad.com/api/v1' end
Public Instance Methods
authenticate()
click to toggle source
# File lib/gumrider.rb, line 15 def authenticate response = Crack::JSON.parse Http.post @endpoint + '/sessions', :form => { :email => @email, :password => @password } if response["success"] @token = Base64.encode64(response["token"] + ":") true else false end end
link(id = false)
click to toggle source
# File lib/gumrider.rb, line 26 def link(id = false) Gumrider::Link.new id, @token, @endpoint end
links()
click to toggle source
# File lib/gumrider.rb, line 30 def links response = Crack::JSON.parse Http.with(:Authorization => 'Basic ' + @token).get @endpoint + '/links' if response["success"] links = [] response["links"].each do |item| link = Gumrider::Link.new(false, @token, @endpoint) link.name = item["name"] link.url = item["url"] link.price = item["price"] / 100 link.description = item["description"] link.id = item["id"] link.currency = item["currency"] links.push link end links else [] end end