Class: Moip::Assinaturas::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/moip-assinaturas/client.rb

Class Method Summary collapse

Class Method Details

.activate_subscription(code, opts = {}) ⇒ Object



94
95
96
97
# File 'lib/moip-assinaturas/client.rb', line 94

def activate_subscription(code, opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:put, "/subscriptions/#{code}/activate", opts, true)
end

.cancel_subscription(code, opts = {}) ⇒ Object



99
100
101
102
# File 'lib/moip-assinaturas/client.rb', line 99

def cancel_subscription(code, opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:put, "/subscriptions/#{code}/cancel", opts, true)
end

.create_customer(customer, new_vault, opts = {}) ⇒ Object



44
45
46
47
# File 'lib/moip-assinaturas/client.rb', line 44

def create_customer(customer, new_vault, opts={})
  prepare_options(opts, { body: customer.to_json, headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:post, "/customers?new_vault=#{new_vault}", opts)
end

.create_plan(plan, opts = {}) ⇒ Object



24
25
26
27
# File 'lib/moip-assinaturas/client.rb', line 24

def create_plan(plan, opts={})
  prepare_options(opts, { body: plan.to_json, headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:post, "/plans", opts)
end

.create_subscription(subscription, new_customer, opts = {}) ⇒ Object



69
70
71
72
# File 'lib/moip-assinaturas/client.rb', line 69

def create_subscription(subscription, new_customer, opts={})
  prepare_options(opts, { body: subscription.to_json, headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:post, "/subscriptions?new_customer=#{new_customer}", opts)
end

.details_customer(code, opts = {}) ⇒ Object



59
60
61
62
# File 'lib/moip-assinaturas/client.rb', line 59

def details_customer(code, opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:get, "/customers/#{code}", opts, true)
end

.details_invoice(id, opts = {}) ⇒ Object



109
110
111
112
# File 'lib/moip-assinaturas/client.rb', line 109

def details_invoice(id, opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:get, "/invoices/#{id}", opts, true)
end

.details_payment(id, opts = {}) ⇒ Object



119
120
121
122
# File 'lib/moip-assinaturas/client.rb', line 119

def details_payment(id, opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:get, "/payments/#{id}", opts)
end

.details_plan(code, opts = {}) ⇒ Object



34
35
36
37
# File 'lib/moip-assinaturas/client.rb', line 34

def details_plan(code, opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:get, "/plans/#{code}", opts, true)
end

.details_subscription(code, opts = {}) ⇒ Object



84
85
86
87
# File 'lib/moip-assinaturas/client.rb', line 84

def details_subscription(code, opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:get, "/subscriptions/#{code}", opts, true)
end

.list_customers(opts = {}) ⇒ Object



49
50
51
52
# File 'lib/moip-assinaturas/client.rb', line 49

def list_customers(opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:get, "/customers", opts)
end

.list_invoices(subscription_code, opts = {}) ⇒ Object



104
105
106
107
# File 'lib/moip-assinaturas/client.rb', line 104

def list_invoices(subscription_code, opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:get, "/subscriptions/#{subscription_code}/invoices", opts)
end

.list_payments(invoice_id, opts = {}) ⇒ Object



114
115
116
117
# File 'lib/moip-assinaturas/client.rb', line 114

def list_payments(invoice_id, opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:get, "/invoices/#{invoice_id}/payments", opts)
end

.list_plans(opts = {}) ⇒ Object



29
30
31
32
# File 'lib/moip-assinaturas/client.rb', line 29

def list_plans(opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:get, "/plans", opts)
end

.list_subscriptions(opts = {}) ⇒ Object



79
80
81
82
# File 'lib/moip-assinaturas/client.rb', line 79

def list_subscriptions(opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:get, "/subscriptions", opts)
end

.suspend_subscription(code, opts = {}) ⇒ Object



89
90
91
92
# File 'lib/moip-assinaturas/client.rb', line 89

def suspend_subscription(code, opts={})
  prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:put, "/subscriptions/#{code}/suspend", opts, true)
end

.update_credit_card(customer_code, credit_card, opts = {}) ⇒ Object



64
65
66
67
# File 'lib/moip-assinaturas/client.rb', line 64

def update_credit_card(customer_code, credit_card, opts={})
  prepare_options(opts, { body: credit_card.to_json, headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:put, "/customers/#{customer_code}/billing_infos", opts)
end

.update_customer(code, changes, opts = {}) ⇒ Object



54
55
56
57
# File 'lib/moip-assinaturas/client.rb', line 54

def update_customer(code, changes, opts={})
  prepare_options(opts, { body: changes.to_json, headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:put, "/customers/#{code}", opts, true)
end

.update_plan(plan, opts = {}) ⇒ Object



39
40
41
42
# File 'lib/moip-assinaturas/client.rb', line 39

def update_plan(plan, opts={})
  prepare_options(opts, { body: plan.to_json, headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:put, "/plans/#{plan[:code]}", opts, true)
end

.update_subscription(subscription_code, subscription_changes, opts = {}) ⇒ Object



74
75
76
77
# File 'lib/moip-assinaturas/client.rb', line 74

def update_subscription(subscription_code, subscription_changes, opts={})
  prepare_options(opts, { body: subscription_changes.to_json, headers: { 'Content-Type' => 'application/json' } })
  peform_action!(:put, "/subscriptions/#{subscription_code}", opts, true)
end