Class: Ampsy::Client
- Inherits:
-
Object
- Object
- Ampsy::Client
- Defined in:
- lib/ampsy/client.rb
Instance Method Summary collapse
- #connect_account(brand_id, provider, account_id) ⇒ Object
- #create_card(attributes) ⇒ Object
- #create_flipbook(brand_id, attributes) ⇒ Object
- #current_user ⇒ Object
- #disconnect_account(brand_id, provider) ⇒ Object
- #flips(flipbook_id, timestamp = nil) ⇒ Object
-
#initialize(access_token = nil, host = 'https://ampsy.com') ⇒ Client
constructor
A new instance of Client.
- #overview ⇒ Object
- #plans ⇒ Object
- #subscribe(brand_id, plan_id, card_token, promo_code = nil) ⇒ Object
- #subscription(brand_id) ⇒ Object
Constructor Details
#initialize(access_token = nil, host = 'https://ampsy.com') ⇒ Client
Returns a new instance of Client.
3 4 5 6 |
# File 'lib/ampsy/client.rb', line 3 def initialize(access_token = nil, host = 'https://ampsy.com') @access_token = access_token @host = host end |
Instance Method Details
#connect_account(brand_id, provider, account_id) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/ampsy/client.rb', line 54 def connect_account(brand_id, provider, account_id) raise ArgumentError, 'brand_id is required' unless brand_id raise ArgumentError, 'provider is required' unless provider raise ArgumentError, 'account_id is required' unless account_id post "brands/#{brand_id}/accounts/#{provider}", account_id: account_id end |
#create_card(attributes) ⇒ Object
37 38 39 40 41 |
# File 'lib/ampsy/client.rb', line 37 def create_card(attributes) raise ArgumentError, 'attributes are required' unless attributes post 'cards', card: attributes end |
#create_flipbook(brand_id, attributes) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/ampsy/client.rb', line 20 def create_flipbook(brand_id, attributes) raise ArgumentError, 'brand_id is required' unless brand_id raise ArgumentError, 'attributes are required' unless attributes create "brands/#{brand_id}/flipbooks", data: attributes end |
#current_user ⇒ Object
69 70 71 |
# File 'lib/ampsy/client.rb', line 69 def current_user get 'user' end |
#disconnect_account(brand_id, provider) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/ampsy/client.rb', line 62 def disconnect_account(brand_id, provider) raise ArgumentError, 'brand_id is required' unless brand_id raise ArgumentError, 'provider is required' unless provider delete "brands/#{brand_id}/accounts/#{network}" end |
#flips(flipbook_id, timestamp = nil) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/ampsy/client.rb', line 12 def flips(flipbook_id, = nil) raise ArgumentError, 'flipbook_id is required' unless flipbook_id params = {} params[:timestamp] = if get "flipbooks/#{flipbook_id}/flips", params end |
#overview ⇒ Object
8 9 10 |
# File 'lib/ampsy/client.rb', line 8 def overview get 'overview' end |
#plans ⇒ Object
27 28 29 |
# File 'lib/ampsy/client.rb', line 27 def plans get 'plans' end |
#subscribe(brand_id, plan_id, card_token, promo_code = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ampsy/client.rb', line 43 def subscribe(brand_id, plan_id, card_token, promo_code = nil) raise ArgumentError, 'brand_id is required' unless brand_id raise ArgumentError, 'plan_id is required' unless plan_id raise ArgumentError, 'card_token is required' unless card_token params = { plan_id: plan_id, card: card_token } params[:promo] = promo_code if promo_code put "brands/#{brand_id}/subscription", params end |
#subscription(brand_id) ⇒ Object
31 32 33 34 35 |
# File 'lib/ampsy/client.rb', line 31 def subscription(brand_id) raise ArgumentError, 'brand_id is required' unless brand_id get "brands/#{brand_id}/subscription" end |