moip-assinaturas 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +28 -0
- data/lib/moip-assinaturas/client.rb +74 -34
- data/lib/moip-assinaturas/customer.rb +8 -8
- data/lib/moip-assinaturas/invoice.rb +4 -4
- data/lib/moip-assinaturas/payment.rb +4 -4
- data/lib/moip-assinaturas/plan.rb +8 -8
- data/lib/moip-assinaturas/subscription.rb +10 -10
- data/lib/moip-assinaturas/version.rb +1 -1
- data/spec/fixtures/custom_authentication/create_customer.json +3 -0
- data/spec/fixtures/custom_authentication/create_plan.json +16 -0
- data/spec/fixtures/custom_authentication/create_subscription.json +36 -0
- data/spec/fixtures/custom_authentication/details_customer.json +34 -0
- data/spec/fixtures/custom_authentication/details_invoice.json +36 -0
- data/spec/fixtures/custom_authentication/details_payment.json +34 -0
- data/spec/fixtures/custom_authentication/details_plan.json +18 -0
- data/spec/fixtures/custom_authentication/details_subscription.json +44 -0
- data/spec/fixtures/custom_authentication/list_customers.json +15 -0
- data/spec/fixtures/custom_authentication/list_invoices.json +23 -0
- data/spec/fixtures/custom_authentication/list_payments.json +32 -0
- data/spec/fixtures/custom_authentication/list_plans.json +17 -0
- data/spec/fixtures/custom_authentication/list_subscriptions.json +35 -0
- data/spec/fixtures/custom_authentication/update_credit_card.json +1 -0
- data/spec/fixtures/list_invoices.json +1 -1
- data/spec/moip-assinaturas/customer_spec.rb +59 -0
- data/spec/moip-assinaturas/invoice_spec.rb +27 -0
- data/spec/moip-assinaturas/payment_spec.rb +27 -0
- data/spec/moip-assinaturas/plan_spec.rb +71 -3
- data/spec/moip-assinaturas/subscription_spec.rb +76 -0
- data/spec/spec_helper.rb +6 -0
- metadata +30 -2
data/README.md
CHANGED
@@ -209,6 +209,34 @@ end
|
|
209
209
|
```
|
210
210
|
A ideia da arquitetura da classe Webhooks foi baseada na gem - [https://github.com/xdougx/api-moip-assinaturas](https://github.com/xdougx/api-moip-assinaturas) - substituindo os objetos daquela gem por hashs
|
211
211
|
|
212
|
+
## Múltiplas Contas Moip
|
213
|
+
|
214
|
+
Caso seja preciso utilizar assinaturas com mais de uma conta Moip, basta passar as chaves de acesso na chamada dos métodos demonstrados acima, por exemplo:
|
215
|
+
|
216
|
+
Criar um novo plano:
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
Moip::Assinaturas::Plan.create(plan_attributes, moip_auth: { token: 'TOKEN', key: 'KEY', sandbox: false })
|
220
|
+
```
|
221
|
+
|
222
|
+
Listar todos planos:
|
223
|
+
|
224
|
+
```ruby
|
225
|
+
Moip::Assinaturas::Plan.list(moip_auth: { token: 'TOKEN', key: 'KEY', sandbox: false })
|
226
|
+
```
|
227
|
+
|
228
|
+
Obter detalhes do plano:
|
229
|
+
|
230
|
+
```ruby
|
231
|
+
Moip::Assinaturas::Plan.details(plan_code, moip_auth: { token: 'TOKEN', key: 'KEY', sandbox: false })
|
232
|
+
```
|
233
|
+
|
234
|
+
Atualizar informações do plano:
|
235
|
+
|
236
|
+
```ruby
|
237
|
+
Moip::Assinaturas::Plan.update(plan_attributes, moip_auth: { token: 'TOKEN', key: 'KEY', sandbox: false })
|
238
|
+
```
|
239
|
+
|
212
240
|
## Contribuindo
|
213
241
|
|
214
242
|
1. Fork it
|
@@ -21,76 +21,116 @@ module Moip::Assinaturas
|
|
21
21
|
|
22
22
|
class << self
|
23
23
|
|
24
|
-
def create_plan(plan)
|
25
|
-
|
24
|
+
def create_plan(plan, opts={})
|
25
|
+
prepare_options(opts, { body: plan.to_json, headers: { 'Content-Type' => 'application/json' } })
|
26
|
+
peform_action!(:post, "/plans", opts)
|
26
27
|
end
|
27
28
|
|
28
|
-
def list_plans
|
29
|
-
|
29
|
+
def list_plans(opts={})
|
30
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
31
|
+
peform_action!(:get, "/plans", opts)
|
30
32
|
end
|
31
33
|
|
32
|
-
def details_plan(code)
|
33
|
-
|
34
|
+
def details_plan(code, opts={})
|
35
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
36
|
+
peform_action!(:get, "/plans/#{code}", opts)
|
34
37
|
end
|
35
38
|
|
36
|
-
def update_plan(plan)
|
37
|
-
|
39
|
+
def update_plan(plan, opts={})
|
40
|
+
prepare_options(opts, { body: plan.to_json, headers: { 'Content-Type' => 'application/json' } })
|
41
|
+
peform_action!(:put, "/plans/#{plan[:code]}", opts, true)
|
38
42
|
end
|
39
43
|
|
40
|
-
def create_customer(customer, new_vault)
|
41
|
-
|
44
|
+
def create_customer(customer, new_vault, opts={})
|
45
|
+
prepare_options(opts, { body: customer.to_json, headers: { 'Content-Type' => 'application/json' } })
|
46
|
+
peform_action!(:post, "/customers?new_vault=#{new_vault}", opts)
|
42
47
|
end
|
43
48
|
|
44
|
-
def list_customers
|
45
|
-
|
49
|
+
def list_customers(opts={})
|
50
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
51
|
+
peform_action!(:get, "/customers", opts)
|
46
52
|
end
|
47
53
|
|
48
|
-
def details_customer(code)
|
49
|
-
|
54
|
+
def details_customer(code, opts={})
|
55
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
56
|
+
peform_action!(:get, "/customers/#{code}", opts)
|
50
57
|
end
|
51
58
|
|
52
|
-
def update_credit_card(customer_code, credit_card)
|
53
|
-
|
59
|
+
def update_credit_card(customer_code, credit_card, opts={})
|
60
|
+
prepare_options(opts, { body: credit_card.to_json, headers: { 'Content-Type' => 'application/json' } })
|
61
|
+
peform_action!(:put, "/customers/#{customer_code}/billing_infos", opts)
|
54
62
|
end
|
55
63
|
|
56
|
-
def create_subscription(subscription, new_customer)
|
57
|
-
|
64
|
+
def create_subscription(subscription, new_customer, opts={})
|
65
|
+
prepare_options(opts, { body: subscription.to_json, headers: { 'Content-Type' => 'application/json' } })
|
66
|
+
peform_action!(:post, "/subscriptions?new_customer=#{new_customer}", opts)
|
58
67
|
end
|
59
68
|
|
60
|
-
def list_subscriptions
|
61
|
-
|
69
|
+
def list_subscriptions(opts={})
|
70
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
71
|
+
peform_action!(:get, "/subscriptions", opts)
|
62
72
|
end
|
63
73
|
|
64
|
-
def details_subscription(code)
|
65
|
-
|
74
|
+
def details_subscription(code, opts={})
|
75
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
76
|
+
peform_action!(:get, "/subscriptions/#{code}", opts)
|
66
77
|
end
|
67
78
|
|
68
|
-
def suspend_subscription(code)
|
69
|
-
|
79
|
+
def suspend_subscription(code, opts={})
|
80
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
81
|
+
peform_action!(:put, "/subscriptions/#{code}/suspend", opts, true)
|
70
82
|
end
|
71
83
|
|
72
|
-
def activate_subscription(code)
|
73
|
-
|
84
|
+
def activate_subscription(code, opts={})
|
85
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
86
|
+
peform_action!(:put, "/subscriptions/#{code}/activate", opts, true)
|
74
87
|
end
|
75
88
|
|
76
|
-
def list_invoices(subscription_code)
|
77
|
-
|
89
|
+
def list_invoices(subscription_code, opts={})
|
90
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
91
|
+
peform_action!(:get, "/subscriptions/#{subscription_code}/invoices", opts)
|
78
92
|
end
|
79
93
|
|
80
|
-
def details_invoice(id)
|
81
|
-
|
94
|
+
def details_invoice(id, opts={})
|
95
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
96
|
+
peform_action!(:get, "/invoices/#{id}", opts)
|
82
97
|
end
|
83
98
|
|
84
|
-
def list_payments(invoice_id)
|
85
|
-
|
99
|
+
def list_payments(invoice_id, opts={})
|
100
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
101
|
+
peform_action!(:get, "/invoices/#{invoice_id}/payments", opts)
|
86
102
|
end
|
87
103
|
|
88
|
-
def details_payment(id)
|
89
|
-
|
104
|
+
def details_payment(id, opts={})
|
105
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
106
|
+
peform_action!(:get, "/payments/#{id}", opts)
|
90
107
|
end
|
91
108
|
|
92
109
|
private
|
93
110
|
|
111
|
+
def prepare_options(custom_options, required_options)
|
112
|
+
custom_options.merge!(required_options)
|
113
|
+
|
114
|
+
if custom_options.include?(:moip_auth)
|
115
|
+
custom_options[:basic_auth] = {
|
116
|
+
username: custom_options[:moip_auth][:token],
|
117
|
+
password: custom_options[:moip_auth][:key]
|
118
|
+
}
|
119
|
+
|
120
|
+
if custom_options[:moip_auth].include?(:sandbox)
|
121
|
+
if custom_options[:moip_auth][:sandbox]
|
122
|
+
custom_options[:base_uri] = "https://sandbox.moip.com.br/assinaturas/v1"
|
123
|
+
else
|
124
|
+
custom_options[:base_uri] = "https://api.moip.com.br/assinaturas/v1"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
custom_options.delete(:moip_auth)
|
129
|
+
end
|
130
|
+
|
131
|
+
custom_options
|
132
|
+
end
|
133
|
+
|
94
134
|
def peform_action!(action_name, url, options = {}, accepts_blank_body = false)
|
95
135
|
if (Moip::Assinaturas.token.blank? or Moip::Assinaturas.key.blank?)
|
96
136
|
raise(MissingTokenError, "Informe o token e a key para realizar a autenticação no webservice")
|
@@ -3,8 +3,8 @@ module Moip::Assinaturas
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
|
-
def create(customer, new_valt = true)
|
7
|
-
response = Moip::Assinaturas::Client.create_customer(customer, new_valt)
|
6
|
+
def create(customer, new_valt = true, opts = {})
|
7
|
+
response = Moip::Assinaturas::Client.create_customer(customer, new_valt, opts)
|
8
8
|
hash = JSON.load(response.body).with_indifferent_access
|
9
9
|
|
10
10
|
case response.code
|
@@ -24,8 +24,8 @@ module Moip::Assinaturas
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def list
|
28
|
-
response = Moip::Assinaturas::Client.list_customers
|
27
|
+
def list(opts = {})
|
28
|
+
response = Moip::Assinaturas::Client.list_customers(opts)
|
29
29
|
hash = JSON.load(response.body).with_indifferent_access
|
30
30
|
|
31
31
|
case response.code
|
@@ -39,8 +39,8 @@ module Moip::Assinaturas
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def details(code)
|
43
|
-
response = Moip::Assinaturas::Client.details_customer(code)
|
42
|
+
def details(code, opts = {})
|
43
|
+
response = Moip::Assinaturas::Client.details_customer(code, opts)
|
44
44
|
hash = JSON.load(response.body).with_indifferent_access
|
45
45
|
|
46
46
|
case response.code
|
@@ -54,8 +54,8 @@ module Moip::Assinaturas
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
def update_credit_card(customer_code, credit_card)
|
58
|
-
response = Moip::Assinaturas::Client.update_credit_card(customer_code, credit_card)
|
57
|
+
def update_credit_card(customer_code, credit_card, opts = {})
|
58
|
+
response = Moip::Assinaturas::Client.update_credit_card(customer_code, credit_card, opts)
|
59
59
|
hash = JSON.load(response.body).with_indifferent_access
|
60
60
|
|
61
61
|
case response.code
|
@@ -3,8 +3,8 @@ module Moip::Assinaturas
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
|
-
def list(subscription_code)
|
7
|
-
response = Moip::Assinaturas::Client.list_invoices(subscription_code)
|
6
|
+
def list(subscription_code, opts={})
|
7
|
+
response = Moip::Assinaturas::Client.list_invoices(subscription_code, opts)
|
8
8
|
hash = JSON.load(response.body).with_indifferent_access
|
9
9
|
|
10
10
|
case response.code
|
@@ -18,8 +18,8 @@ module Moip::Assinaturas
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def details(id)
|
22
|
-
response = Moip::Assinaturas::Client.details_invoice(id)
|
21
|
+
def details(id, opts={})
|
22
|
+
response = Moip::Assinaturas::Client.details_invoice(id, opts)
|
23
23
|
hash = JSON.load(response.body).with_indifferent_access
|
24
24
|
|
25
25
|
case response.code
|
@@ -3,8 +3,8 @@ module Moip::Assinaturas
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
|
-
def list(invoice_id)
|
7
|
-
response = Moip::Assinaturas::Client.list_payments(invoice_id)
|
6
|
+
def list(invoice_id, opts={})
|
7
|
+
response = Moip::Assinaturas::Client.list_payments(invoice_id, opts)
|
8
8
|
hash = JSON.load(response.body).with_indifferent_access
|
9
9
|
|
10
10
|
case response.code
|
@@ -18,8 +18,8 @@ module Moip::Assinaturas
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def details(id)
|
22
|
-
response = Moip::Assinaturas::Client.details_payment(id)
|
21
|
+
def details(id, opts={})
|
22
|
+
response = Moip::Assinaturas::Client.details_payment(id, opts)
|
23
23
|
hash = JSON.load(response.body).with_indifferent_access
|
24
24
|
|
25
25
|
case response.code
|
@@ -3,8 +3,8 @@ module Moip::Assinaturas
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
|
-
def create(plan)
|
7
|
-
response = Moip::Assinaturas::Client.create_plan(plan)
|
6
|
+
def create(plan, opts={})
|
7
|
+
response = Moip::Assinaturas::Client.create_plan(plan, opts)
|
8
8
|
hash = JSON.load(response.body).with_indifferent_access
|
9
9
|
|
10
10
|
case response.code
|
@@ -24,8 +24,8 @@ module Moip::Assinaturas
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def list
|
28
|
-
response = Moip::Assinaturas::Client.list_plans
|
27
|
+
def list(opts={})
|
28
|
+
response = Moip::Assinaturas::Client.list_plans(opts)
|
29
29
|
hash = JSON.load(response.body).with_indifferent_access
|
30
30
|
|
31
31
|
case response.code
|
@@ -39,8 +39,8 @@ module Moip::Assinaturas
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def details(code)
|
43
|
-
response = Moip::Assinaturas::Client.details_plan(code)
|
42
|
+
def details(code, opts={})
|
43
|
+
response = Moip::Assinaturas::Client.details_plan(code, opts)
|
44
44
|
hash = JSON.load(response.body).with_indifferent_access
|
45
45
|
|
46
46
|
case response.code
|
@@ -54,8 +54,8 @@ module Moip::Assinaturas
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
def update(plan)
|
58
|
-
response = Moip::Assinaturas::Client.update_plan(plan)
|
57
|
+
def update(plan, opts={})
|
58
|
+
response = Moip::Assinaturas::Client.update_plan(plan, opts)
|
59
59
|
|
60
60
|
# in the current implementation the Moip signatures API only
|
61
61
|
# returns response code 200 with an empty body even if the update fails
|
@@ -3,8 +3,8 @@ module Moip::Assinaturas
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
|
-
def create(subscription, new_customer = false)
|
7
|
-
response = Moip::Assinaturas::Client.create_subscription(subscription, new_customer)
|
6
|
+
def create(subscription, new_customer = false, opts={})
|
7
|
+
response = Moip::Assinaturas::Client.create_subscription(subscription, new_customer, opts)
|
8
8
|
hash = JSON.load(response.body).with_indifferent_access
|
9
9
|
|
10
10
|
case response.code
|
@@ -25,8 +25,8 @@ module Moip::Assinaturas
|
|
25
25
|
|
26
26
|
end
|
27
27
|
|
28
|
-
def list
|
29
|
-
response = Moip::Assinaturas::Client.list_subscriptions
|
28
|
+
def list(opts={})
|
29
|
+
response = Moip::Assinaturas::Client.list_subscriptions(opts)
|
30
30
|
hash = JSON.load(response.body).with_indifferent_access
|
31
31
|
|
32
32
|
case response.code
|
@@ -41,8 +41,8 @@ module Moip::Assinaturas
|
|
41
41
|
|
42
42
|
end
|
43
43
|
|
44
|
-
def details(code)
|
45
|
-
response = Moip::Assinaturas::Client.details_subscription(code)
|
44
|
+
def details(code, opts={})
|
45
|
+
response = Moip::Assinaturas::Client.details_subscription(code, opts)
|
46
46
|
hash = JSON.load(response.body).with_indifferent_access
|
47
47
|
|
48
48
|
case response.code
|
@@ -56,8 +56,8 @@ module Moip::Assinaturas
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
def suspend(code)
|
60
|
-
response = Moip::Assinaturas::Client.suspend_subscription(code)
|
59
|
+
def suspend(code, opts={})
|
60
|
+
response = Moip::Assinaturas::Client.suspend_subscription(code, opts)
|
61
61
|
|
62
62
|
case response.code
|
63
63
|
when 200
|
@@ -67,8 +67,8 @@ module Moip::Assinaturas
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
def activate(code)
|
71
|
-
response = Moip::Assinaturas::Client.activate_subscription(code)
|
70
|
+
def activate(code, opts={})
|
71
|
+
response = Moip::Assinaturas::Client.activate_subscription(code, opts)
|
72
72
|
|
73
73
|
case response.code
|
74
74
|
when 200
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"code": "plano02",
|
3
|
+
"name": "Plano Especial 2",
|
4
|
+
"description": "Descrição do Plano Especial 2",
|
5
|
+
"amount": 490, //em centavos
|
6
|
+
"setup_fee": 200, //em centavos
|
7
|
+
"max_qty": 2,
|
8
|
+
"interval": {
|
9
|
+
"length": 3,
|
10
|
+
"unit": "MONTH"
|
11
|
+
},
|
12
|
+
"trial": {
|
13
|
+
"enabled": true,
|
14
|
+
"days": 15
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"code": "ass_homolog_72",
|
3
|
+
"amount": "100",
|
4
|
+
"next_invoice_date": {
|
5
|
+
"day": "05",
|
6
|
+
"month": "01",
|
7
|
+
"year": "2013"
|
8
|
+
},
|
9
|
+
"status": "ACTIVE",
|
10
|
+
"plan": {
|
11
|
+
"name": "Plano de homologação",
|
12
|
+
"code": "homolog1"
|
13
|
+
},
|
14
|
+
"customer": {
|
15
|
+
"email": "fulano@homolog.com",
|
16
|
+
"code": "homolog2",
|
17
|
+
"fullname": "Fulano Homologador"
|
18
|
+
},
|
19
|
+
"invoice": { //dados da primeira cobrança (se houver)
|
20
|
+
"id": 134,
|
21
|
+
"moip_id": "14000000",
|
22
|
+
"amount": 110,
|
23
|
+
"status": {
|
24
|
+
"description": "Em análise",
|
25
|
+
"code": 2
|
26
|
+
}
|
27
|
+
},
|
28
|
+
"message": "Assinatura criada com Sucesso",
|
29
|
+
"errors": [],
|
30
|
+
"alerts": [
|
31
|
+
{
|
32
|
+
"code": "MA90",
|
33
|
+
"description": "O nome do portador do cartão deve ter no máximo 45 caracteres. Os demais caracteres foram ignorados"
|
34
|
+
}
|
35
|
+
]
|
36
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"code": "19",
|
3
|
+
"fullname": "Nome Sobrenome",
|
4
|
+
"email": "nome@exemplo.com",
|
5
|
+
"cpf": "22222222222",
|
6
|
+
"phone_area_code": "11",
|
7
|
+
"phone_number": "990909090",
|
8
|
+
"birthdate_day": 29,
|
9
|
+
"birthdate_month": 3,
|
10
|
+
"birthdate_year": 1980,
|
11
|
+
"address": {
|
12
|
+
"street": "Rua Nome da Rua",
|
13
|
+
"number": "1000",
|
14
|
+
"complement": "Apto 4 - bloco A",
|
15
|
+
"district": "Bairro",
|
16
|
+
"city": "São Paulo",
|
17
|
+
"state": "SP",
|
18
|
+
"country": "BRA",
|
19
|
+
"zipcode": "00000000"
|
20
|
+
},
|
21
|
+
"billing_info": {
|
22
|
+
"credit_cards": [
|
23
|
+
{
|
24
|
+
"vault": "00b21555-296a-4e70-94cd-3e96fef62e5b",
|
25
|
+
"brand": "VISA",
|
26
|
+
"first_six_digits": "411111",
|
27
|
+
"last_four_digits": "1111",
|
28
|
+
"expiration_month": "04",
|
29
|
+
"expiration_year": "15",
|
30
|
+
"holder_name": "Nome Sobrenome"
|
31
|
+
}
|
32
|
+
]
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"id": 14,
|
3
|
+
"amount": 101,
|
4
|
+
"subscription_code": "assinatura7",
|
5
|
+
"occurrence": 1,
|
6
|
+
"status": {
|
7
|
+
"code": 2,
|
8
|
+
"description": "Aguardando confirmação"
|
9
|
+
},
|
10
|
+
"items": [
|
11
|
+
{
|
12
|
+
"amount": 100,
|
13
|
+
"type": "Valor da assinatura"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"amount": 1,
|
17
|
+
"type": "Taxa de contratação"
|
18
|
+
}
|
19
|
+
],
|
20
|
+
"plan": {
|
21
|
+
"code": "plano1",
|
22
|
+
"name": "Plano 1 real"
|
23
|
+
},
|
24
|
+
"customer": {
|
25
|
+
"code": "cliente1",
|
26
|
+
"fullname": "Fulano Testador"
|
27
|
+
},
|
28
|
+
"creation_date": {
|
29
|
+
"day": 28,
|
30
|
+
"month": 12,
|
31
|
+
"year": 2012,
|
32
|
+
"hour": 15,
|
33
|
+
"minute": 38,
|
34
|
+
"second": 41
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"id": 7,
|
3
|
+
"moip_id": 7205895,
|
4
|
+
"status": {
|
5
|
+
"code": 6,
|
6
|
+
"description": "Em análise"
|
7
|
+
},
|
8
|
+
"subscription_code": "assinatura7",
|
9
|
+
"customer_code": "cliente1",
|
10
|
+
"invoice": {
|
11
|
+
"id": 13,
|
12
|
+
"amount": 101
|
13
|
+
},
|
14
|
+
"payment_method": {
|
15
|
+
"code": 1,
|
16
|
+
"description": "Cartão de Crédito",
|
17
|
+
"credit_card": {
|
18
|
+
"brand": "VISA",
|
19
|
+
"holder_name": "Fulano Testador",
|
20
|
+
"first_six_digits": "411111",
|
21
|
+
"last_four_digits": "1111",
|
22
|
+
"expiration_month": "03",
|
23
|
+
"expiration_year": "16"
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"creation_date": {
|
27
|
+
"day": 28,
|
28
|
+
"month": 12,
|
29
|
+
"year": 2012,
|
30
|
+
"hour": 15,
|
31
|
+
"minute": 38,
|
32
|
+
"second": 41
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"code": "plano02",
|
3
|
+
"name": "Plano Ouro Ilimitado",
|
4
|
+
"description": "Plano com todas as vantagens",
|
5
|
+
"status": "ACTIVE",
|
6
|
+
"amount": 2990,
|
7
|
+
"max_qty": 50,
|
8
|
+
"setup_fee": 1000,
|
9
|
+
"interval": {
|
10
|
+
"length": 1,
|
11
|
+
"unit": "MONTH"
|
12
|
+
},
|
13
|
+
"billing_cycles": 1,
|
14
|
+
"trial": {
|
15
|
+
"enabled": true,
|
16
|
+
"days": 10
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
{
|
2
|
+
"code": "assinatura2",
|
3
|
+
"amount": "100",
|
4
|
+
"status": "ACTIVE",
|
5
|
+
"creation_date": {
|
6
|
+
"day": "20",
|
7
|
+
"month": "10",
|
8
|
+
"year": "2012",
|
9
|
+
"hour": "20",
|
10
|
+
"minute": "00",
|
11
|
+
"second": "00"
|
12
|
+
},
|
13
|
+
"next_invoice_date": {
|
14
|
+
"day": "20",
|
15
|
+
"month": "11",
|
16
|
+
"year": "2012"
|
17
|
+
},
|
18
|
+
"expiration_date": {
|
19
|
+
"day": "20",
|
20
|
+
"month": "10",
|
21
|
+
"year": "2013"
|
22
|
+
},
|
23
|
+
"plan": {
|
24
|
+
"name": "Plano Ouro Ilimitado",
|
25
|
+
"code": "plano1"
|
26
|
+
},
|
27
|
+
"customer": {
|
28
|
+
"code": "cliente1",
|
29
|
+
"fullname": "Nome e Sobrenome",
|
30
|
+
"email": "assinaturas@moip.com.br"
|
31
|
+
},
|
32
|
+
"trial": {
|
33
|
+
"start": {
|
34
|
+
"month": 9,
|
35
|
+
"year": 2013,
|
36
|
+
"day": 27
|
37
|
+
},
|
38
|
+
"end": {
|
39
|
+
"month": 10,
|
40
|
+
"year": 2013,
|
41
|
+
"day": 17
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"customers": [
|
3
|
+
{
|
4
|
+
"code": "cliente1",
|
5
|
+
"fullname": "Nome Sobrenome",
|
6
|
+
"email": "nome@exemplo.com",
|
7
|
+
"cpf": "22222222222",
|
8
|
+
"phone_area_code": "11",
|
9
|
+
"phone_number": "990909090",
|
10
|
+
"birthdate_day": "29",
|
11
|
+
"birthdate_month": "04",
|
12
|
+
"birthdate_year": "1980"
|
13
|
+
}
|
14
|
+
]
|
15
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"invoices": [
|
3
|
+
{
|
4
|
+
"id": 14,
|
5
|
+
"amount": 101,
|
6
|
+
"subscription_code": "assinatura7",
|
7
|
+
|
8
|
+
"occurrence": 1,
|
9
|
+
"status": {
|
10
|
+
"code": 2,
|
11
|
+
"description": "Aguardando confirmação"
|
12
|
+
},
|
13
|
+
"creation_date": {
|
14
|
+
"day": 28,
|
15
|
+
"month": 12,
|
16
|
+
"year": 2012,
|
17
|
+
"hour": 15,
|
18
|
+
"minute": 38,
|
19
|
+
"second": 41
|
20
|
+
}
|
21
|
+
}
|
22
|
+
]
|
23
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
{
|
2
|
+
"payments": [
|
3
|
+
{
|
4
|
+
"id": 7,
|
5
|
+
"moip_id": 7205895,
|
6
|
+
"status": {
|
7
|
+
"code": 6,
|
8
|
+
"description": "Em análise"
|
9
|
+
},
|
10
|
+
"payment_method": {
|
11
|
+
"code": 1,
|
12
|
+
"description": "Cartão de Crédito",
|
13
|
+
"credit_card": {
|
14
|
+
"brand": "VISA",
|
15
|
+
"holder_name": "Fulano Testador",
|
16
|
+
"first_six_digits": "411111",
|
17
|
+
"last_four_digits": "1111",
|
18
|
+
"expiration_month": "03",
|
19
|
+
"expiration_year": "16"
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"creation_date": {
|
23
|
+
"day": 28,
|
24
|
+
"month": 12,
|
25
|
+
"year": 2012,
|
26
|
+
"hour": 15,
|
27
|
+
"minute": 38,
|
28
|
+
"second": 41
|
29
|
+
}
|
30
|
+
}
|
31
|
+
]
|
32
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"plans": [
|
3
|
+
{
|
4
|
+
"code": "plano02",
|
5
|
+
"name": "Plano Especial 2",
|
6
|
+
"description": "Descrição do Plano Especial 2",
|
7
|
+
"amount": 490, //em centavos
|
8
|
+
"setup_fee": 200, //em centavos
|
9
|
+
"max_qty": 2,
|
10
|
+
"interval": {
|
11
|
+
"length": 3,
|
12
|
+
"unit": "MONTH"
|
13
|
+
},
|
14
|
+
"billing_cycles": 1
|
15
|
+
}
|
16
|
+
]
|
17
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"subscriptions": [
|
3
|
+
{
|
4
|
+
"code": "assinatura2",
|
5
|
+
"amount": "100",
|
6
|
+
"status": "ACTIVE",
|
7
|
+
"creation_date": {
|
8
|
+
"day": "20",
|
9
|
+
"month": "10",
|
10
|
+
"year": "2012",
|
11
|
+
"hour": "20",
|
12
|
+
"minute": "00",
|
13
|
+
"second": "00"
|
14
|
+
},
|
15
|
+
"next_invoice_date": {
|
16
|
+
"day": "20",
|
17
|
+
"month": "11",
|
18
|
+
"year": "2012"
|
19
|
+
},
|
20
|
+
"expiration_date": {
|
21
|
+
"day": "20",
|
22
|
+
"month": "10",
|
23
|
+
"year": "2013"
|
24
|
+
},
|
25
|
+
"plan": {
|
26
|
+
"name": "Plano Ouro Ilimitado",
|
27
|
+
"code": "plano1"
|
28
|
+
},
|
29
|
+
"customer": {
|
30
|
+
"code": "cliente1",
|
31
|
+
"fullname": "Nome e sobrenome"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{ "message": "Dados alterados com sucesso" }
|
@@ -61,6 +61,34 @@ describe Moip::Assinaturas::Customer do
|
|
61
61
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'update_credit_card.json'),
|
62
62
|
status: [200, 'OK']
|
63
63
|
)
|
64
|
+
|
65
|
+
FakeWeb.register_uri(
|
66
|
+
:post,
|
67
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers?new_vault=true",
|
68
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'create_customer.json'),
|
69
|
+
status: [201, 'CREATED']
|
70
|
+
)
|
71
|
+
|
72
|
+
FakeWeb.register_uri(
|
73
|
+
:get,
|
74
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers",
|
75
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'list_customers.json'),
|
76
|
+
status: [200, 'OK']
|
77
|
+
)
|
78
|
+
|
79
|
+
FakeWeb.register_uri(
|
80
|
+
:get,
|
81
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers/18",
|
82
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'details_customer.json'),
|
83
|
+
status: [200, 'OK']
|
84
|
+
)
|
85
|
+
|
86
|
+
FakeWeb.register_uri(
|
87
|
+
:put,
|
88
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers/19/billing_infos",
|
89
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'update_credit_card.json'),
|
90
|
+
status: [200, 'OK']
|
91
|
+
)
|
64
92
|
end
|
65
93
|
|
66
94
|
it "should create a new customer" do
|
@@ -93,4 +121,35 @@ describe Moip::Assinaturas::Customer do
|
|
93
121
|
request[:success].should be_true
|
94
122
|
end
|
95
123
|
|
124
|
+
context "Custom Authentication" do
|
125
|
+
it "should create a new customer in other moip account" do
|
126
|
+
request = Moip::Assinaturas::Customer.create(@customer, true, moip_auth: $custom_moip_auth)
|
127
|
+
request[:success].should be_true
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should list all customers from custom moip account" do
|
131
|
+
request = Moip::Assinaturas::Customer.list(moip_auth: $custom_moip_auth)
|
132
|
+
request[:success].should be_true
|
133
|
+
request[:customers].size.should == 1
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should get the customer details of custom moip account" do
|
137
|
+
request = Moip::Assinaturas::Customer.details('18', moip_auth: $custom_moip_auth)
|
138
|
+
request[:success].should be_true
|
139
|
+
request[:customer][:code].should == '19'
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should update the customer card info from custom moip account" do
|
143
|
+
request = Moip::Assinaturas::Customer.update_credit_card(19, {
|
144
|
+
credit_card: {
|
145
|
+
holder_name: 'Novo nome 2',
|
146
|
+
number: '5555666677778884',
|
147
|
+
expiration_month: '04',
|
148
|
+
expiration_year: '15'
|
149
|
+
}
|
150
|
+
}, moip_auth: $custom_moip_auth)
|
151
|
+
|
152
|
+
request[:success].should be_true
|
153
|
+
end
|
154
|
+
end
|
96
155
|
end
|
@@ -19,6 +19,20 @@ describe Moip::Assinaturas::Invoice do
|
|
19
19
|
status: [200, 'OK']
|
20
20
|
)
|
21
21
|
|
22
|
+
FakeWeb.register_uri(
|
23
|
+
:get,
|
24
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/subscriptions/assinatura2/invoices",
|
25
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'list_invoices.json'),
|
26
|
+
status: [200, 'OK']
|
27
|
+
)
|
28
|
+
|
29
|
+
FakeWeb.register_uri(
|
30
|
+
:get,
|
31
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/invoices/14",
|
32
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'details_invoice.json'),
|
33
|
+
status: [200, 'OK']
|
34
|
+
)
|
35
|
+
|
22
36
|
end
|
23
37
|
|
24
38
|
it "should list all invoices from a subscription" do
|
@@ -32,4 +46,17 @@ describe Moip::Assinaturas::Invoice do
|
|
32
46
|
request[:invoice][:id].should == 13
|
33
47
|
end
|
34
48
|
|
49
|
+
context "Custom Authentication" do
|
50
|
+
it "should list all invoices from a subscription from a custom moip account" do
|
51
|
+
request = Moip::Assinaturas::Invoice.list('assinatura2', moip_auth: $custom_moip_auth)
|
52
|
+
request[:success].should be_true
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should get the invoice details from a custom moip account" do
|
56
|
+
request = Moip::Assinaturas::Invoice.details(14, moip_auth: $custom_moip_auth)
|
57
|
+
request[:success].should be_true
|
58
|
+
request[:invoice][:id].should == 14
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
35
62
|
end
|
@@ -19,6 +19,20 @@ describe Moip::Assinaturas::Payment do
|
|
19
19
|
status: [200, 'OK']
|
20
20
|
)
|
21
21
|
|
22
|
+
FakeWeb.register_uri(
|
23
|
+
:get,
|
24
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/invoices/14/payments",
|
25
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'list_payments.json'),
|
26
|
+
status: [200, 'OK']
|
27
|
+
)
|
28
|
+
|
29
|
+
FakeWeb.register_uri(
|
30
|
+
:get,
|
31
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/payments/7",
|
32
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'details_payment.json'),
|
33
|
+
status: [200, 'OK']
|
34
|
+
)
|
35
|
+
|
22
36
|
end
|
23
37
|
|
24
38
|
it "should get all payments from a invoice" do
|
@@ -33,4 +47,17 @@ describe Moip::Assinaturas::Payment do
|
|
33
47
|
request[:payment][:id].should == 6
|
34
48
|
end
|
35
49
|
|
50
|
+
context "Custom Authentication" do
|
51
|
+
it "should get all payments from a invoice" do
|
52
|
+
request = Moip::Assinaturas::Payment.list(14, moip_auth: $custom_moip_auth)
|
53
|
+
request[:success].should be_true
|
54
|
+
request[:payments].size.should == 1
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should get details of a payment" do
|
58
|
+
request = Moip::Assinaturas::Payment.details(7, moip_auth: $custom_moip_auth)
|
59
|
+
request[:success].should be_true
|
60
|
+
request[:payment][:id].should == 7
|
61
|
+
end
|
62
|
+
end
|
36
63
|
end
|
@@ -22,8 +22,23 @@ describe Moip::Assinaturas::Plan do
|
|
22
22
|
}
|
23
23
|
}
|
24
24
|
|
25
|
-
@
|
26
|
-
|
25
|
+
@plan2 = {
|
26
|
+
code: "plano02",
|
27
|
+
name: "Plano Especial 2",
|
28
|
+
description: "Descrição do Plano Especial 2",
|
29
|
+
amount: 490,
|
30
|
+
setup_fee: 200,
|
31
|
+
max_qty: 2,
|
32
|
+
interval: {
|
33
|
+
length: 3,
|
34
|
+
unit: "MONTH"
|
35
|
+
},
|
36
|
+
billing_cycles: 12,
|
37
|
+
trial: {
|
38
|
+
enabled: true,
|
39
|
+
days: 15
|
40
|
+
}
|
41
|
+
}
|
27
42
|
|
28
43
|
FakeWeb.register_uri(
|
29
44
|
:post,
|
@@ -52,6 +67,34 @@ describe Moip::Assinaturas::Plan do
|
|
52
67
|
body: "",
|
53
68
|
status: [200, 'OK']
|
54
69
|
)
|
70
|
+
|
71
|
+
FakeWeb.register_uri(
|
72
|
+
:post,
|
73
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans",
|
74
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'create_plan.json'),
|
75
|
+
status: [201, 'OK']
|
76
|
+
)
|
77
|
+
|
78
|
+
FakeWeb.register_uri(
|
79
|
+
:get,
|
80
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans",
|
81
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'list_plans.json'),
|
82
|
+
status: [200, 'OK']
|
83
|
+
)
|
84
|
+
|
85
|
+
FakeWeb.register_uri(
|
86
|
+
:get,
|
87
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans/plano02",
|
88
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'details_plan.json'),
|
89
|
+
status: [200, 'OK']
|
90
|
+
)
|
91
|
+
|
92
|
+
FakeWeb.register_uri(
|
93
|
+
:put,
|
94
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans/plano02",
|
95
|
+
body: "",
|
96
|
+
status: [200, 'OK']
|
97
|
+
)
|
55
98
|
end
|
56
99
|
|
57
100
|
it "should can create a new plan" do
|
@@ -73,7 +116,7 @@ describe Moip::Assinaturas::Plan do
|
|
73
116
|
end
|
74
117
|
|
75
118
|
it "should update an existing plan" do
|
76
|
-
request = Moip::Assinaturas::Plan.update(@
|
119
|
+
request = Moip::Assinaturas::Plan.update(@plan)
|
77
120
|
request[:success].should be_true
|
78
121
|
end
|
79
122
|
|
@@ -85,4 +128,29 @@ describe Moip::Assinaturas::Plan do
|
|
85
128
|
end
|
86
129
|
end
|
87
130
|
|
131
|
+
context "Custom Authentication" do
|
132
|
+
it "should create a new plan in other moip account" do
|
133
|
+
request = Moip::Assinaturas::Plan.create(@plan2, moip_auth: $custom_moip_auth)
|
134
|
+
request[:success].should be_true
|
135
|
+
request[:plan][:code].should == 'plano02'
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should list all plans from other moip account" do
|
139
|
+
request = Moip::Assinaturas::Plan.list(moip_auth: $custom_moip_auth)
|
140
|
+
request[:success].should be_true
|
141
|
+
request[:plans].size.should == 1
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should get details from a plan of other moip account" do
|
145
|
+
request = Moip::Assinaturas::Plan.details('plano02', moip_auth: $custom_moip_auth)
|
146
|
+
request[:success].should be_true
|
147
|
+
request[:plan][:code].should == 'plano02'
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should update an existing plan of other moip account" do
|
151
|
+
request = Moip::Assinaturas::Plan.update(@plan2, moip_auth: $custom_moip_auth)
|
152
|
+
request[:success].should be_true
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
88
156
|
end
|
@@ -22,6 +22,17 @@ describe Moip::Assinaturas::Subscription do
|
|
22
22
|
}
|
23
23
|
}
|
24
24
|
|
25
|
+
@subscription2 = {
|
26
|
+
code: "assinatura2",
|
27
|
+
amount: "100",
|
28
|
+
plan: {
|
29
|
+
code: "plano2"
|
30
|
+
},
|
31
|
+
customer: {
|
32
|
+
code: "19"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
25
36
|
FakeWeb.register_uri(
|
26
37
|
:post,
|
27
38
|
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/subscriptions?new_customer=false",
|
@@ -56,6 +67,41 @@ describe Moip::Assinaturas::Subscription do
|
|
56
67
|
body: '',
|
57
68
|
status: [200, 'OK']
|
58
69
|
)
|
70
|
+
|
71
|
+
FakeWeb.register_uri(
|
72
|
+
:post,
|
73
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/subscriptions?new_customer=false",
|
74
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'create_subscription.json'),
|
75
|
+
status: [201, 'CREATED']
|
76
|
+
)
|
77
|
+
|
78
|
+
FakeWeb.register_uri(
|
79
|
+
:get,
|
80
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/subscriptions",
|
81
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'list_subscriptions.json'),
|
82
|
+
status: [200, 'OK']
|
83
|
+
)
|
84
|
+
|
85
|
+
FakeWeb.register_uri(
|
86
|
+
:get,
|
87
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/subscriptions/assinatura2",
|
88
|
+
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'details_subscription.json'),
|
89
|
+
status: [200, 'OK']
|
90
|
+
)
|
91
|
+
|
92
|
+
FakeWeb.register_uri(
|
93
|
+
:put,
|
94
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/subscriptions/assinatura2/activate",
|
95
|
+
body: '',
|
96
|
+
status: [200, 'OK']
|
97
|
+
)
|
98
|
+
|
99
|
+
FakeWeb.register_uri(
|
100
|
+
:put,
|
101
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/subscriptions/assinatura2/suspend",
|
102
|
+
body: '',
|
103
|
+
status: [200, 'OK']
|
104
|
+
)
|
59
105
|
end
|
60
106
|
|
61
107
|
it "should create a new subscription" do
|
@@ -93,4 +139,34 @@ describe Moip::Assinaturas::Subscription do
|
|
93
139
|
end
|
94
140
|
end
|
95
141
|
|
142
|
+
context "Custom Authentication" do
|
143
|
+
it "should create a new subscription from a custom moip account" do
|
144
|
+
request = Moip::Assinaturas::Subscription.create(@subscription, false, moip_auth: $custom_moip_auth)
|
145
|
+
request[:success].should be_true
|
146
|
+
request[:subscription][:code].should == 'ass_homolog_72'
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should list all subscriptions from a custom moip account" do
|
150
|
+
request = Moip::Assinaturas::Subscription.list(moip_auth: $custom_moip_auth)
|
151
|
+
request[:success].should be_true
|
152
|
+
request[:subscriptions].size.should == 1
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should get the subscription details from a custom moip account" do
|
156
|
+
request = Moip::Assinaturas::Subscription.details('assinatura2', moip_auth: $custom_moip_auth)
|
157
|
+
request[:success].should be_true
|
158
|
+
request[:subscription][:code].should == 'assinatura2'
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should suspend a subscription from a custom moip account" do
|
162
|
+
request = Moip::Assinaturas::Subscription.suspend('assinatura2', moip_auth: $custom_moip_auth)
|
163
|
+
request[:success].should be_true
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should reactive a subscription from a custom moip account" do
|
167
|
+
request = Moip::Assinaturas::Subscription.activate('assinatura2', moip_auth: $custom_moip_auth)
|
168
|
+
request[:success].should be_true
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
96
172
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moip-assinaturas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -167,6 +167,20 @@ files:
|
|
167
167
|
- spec/fixtures/create_customer.json
|
168
168
|
- spec/fixtures/create_plan.json
|
169
169
|
- spec/fixtures/create_subscription.json
|
170
|
+
- spec/fixtures/custom_authentication/create_customer.json
|
171
|
+
- spec/fixtures/custom_authentication/create_plan.json
|
172
|
+
- spec/fixtures/custom_authentication/create_subscription.json
|
173
|
+
- spec/fixtures/custom_authentication/details_customer.json
|
174
|
+
- spec/fixtures/custom_authentication/details_invoice.json
|
175
|
+
- spec/fixtures/custom_authentication/details_payment.json
|
176
|
+
- spec/fixtures/custom_authentication/details_plan.json
|
177
|
+
- spec/fixtures/custom_authentication/details_subscription.json
|
178
|
+
- spec/fixtures/custom_authentication/list_customers.json
|
179
|
+
- spec/fixtures/custom_authentication/list_invoices.json
|
180
|
+
- spec/fixtures/custom_authentication/list_payments.json
|
181
|
+
- spec/fixtures/custom_authentication/list_plans.json
|
182
|
+
- spec/fixtures/custom_authentication/list_subscriptions.json
|
183
|
+
- spec/fixtures/custom_authentication/update_credit_card.json
|
170
184
|
- spec/fixtures/details_customer.json
|
171
185
|
- spec/fixtures/details_invoice.json
|
172
186
|
- spec/fixtures/details_payment.json
|
@@ -214,6 +228,20 @@ test_files:
|
|
214
228
|
- spec/fixtures/create_customer.json
|
215
229
|
- spec/fixtures/create_plan.json
|
216
230
|
- spec/fixtures/create_subscription.json
|
231
|
+
- spec/fixtures/custom_authentication/create_customer.json
|
232
|
+
- spec/fixtures/custom_authentication/create_plan.json
|
233
|
+
- spec/fixtures/custom_authentication/create_subscription.json
|
234
|
+
- spec/fixtures/custom_authentication/details_customer.json
|
235
|
+
- spec/fixtures/custom_authentication/details_invoice.json
|
236
|
+
- spec/fixtures/custom_authentication/details_payment.json
|
237
|
+
- spec/fixtures/custom_authentication/details_plan.json
|
238
|
+
- spec/fixtures/custom_authentication/details_subscription.json
|
239
|
+
- spec/fixtures/custom_authentication/list_customers.json
|
240
|
+
- spec/fixtures/custom_authentication/list_invoices.json
|
241
|
+
- spec/fixtures/custom_authentication/list_payments.json
|
242
|
+
- spec/fixtures/custom_authentication/list_plans.json
|
243
|
+
- spec/fixtures/custom_authentication/list_subscriptions.json
|
244
|
+
- spec/fixtures/custom_authentication/update_credit_card.json
|
217
245
|
- spec/fixtures/details_customer.json
|
218
246
|
- spec/fixtures/details_invoice.json
|
219
247
|
- spec/fixtures/details_payment.json
|