myfinance 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +99 -1
- data/lib/myfinance.rb +6 -0
- data/lib/myfinance/client.rb +8 -0
- data/lib/myfinance/entities/tax.rb +10 -0
- data/lib/myfinance/entities/tax_collection.rb +18 -0
- data/lib/myfinance/entities/webhook.rb +14 -0
- data/lib/myfinance/entities/webhook_collection.rb +16 -0
- data/lib/myfinance/resources/tax.rb +39 -0
- data/lib/myfinance/resources/webhook.rb +83 -0
- data/lib/myfinance/version.rb +1 -1
- data/spec/lib/myfinance/client_spec.rb +14 -0
- data/spec/lib/myfinance/entities/tax_collection_spec.rb +23 -0
- data/spec/lib/myfinance/entities/tax_spec.rb +5 -0
- data/spec/lib/myfinance/entities/webhook_collection_spec.rb +48 -0
- data/spec/lib/myfinance/entities/webhook_spec.rb +10 -0
- data/spec/lib/myfinance/resources/tax_spec.rb +50 -0
- data/spec/lib/myfinance/resources/webhook_spec.rb +120 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecda9fc35e75861ba16e84234727cfa22b373195
|
4
|
+
data.tar.gz: 9b84355ad4ecfba37229a672881990f14392629f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e0a5874346c8d48b939caa538e287aa421774b58eac2d9f175abcd2330f5f9e2d2bb0f3197fc031f8f391376c37a93dfddf0aa6f078541d651164a384906b8f
|
7
|
+
data.tar.gz: 989b52db753b0bf88c121001ea05090a8185b710a3de13213ae63aa6c8a1ea4fc22035e6019599aa7ec6c9761627faa0cc0bd786532158ad056937233655d028
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -44,6 +44,8 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
|
|
44
44
|
* [Categories API](https://app.myfinance.com.br/docs/api/categories) as `client.categories`
|
45
45
|
* [ClassificationCenters API](https://app.myfinance.com.br/docs/api/classification_centers) as `client.classification_centers`
|
46
46
|
* [People API](https://app.myfinance.com.br/docs/api/people) as `client.people`
|
47
|
+
* [Webhooks API](https://app.myfinance.com.br/docs/api/webhooks) as `client.webhooks`
|
48
|
+
* [Taxes API](https://app.myfinance.com.br/docs/api/taxes) as `client.taxes`
|
47
49
|
|
48
50
|
### Endpoints
|
49
51
|
|
@@ -360,7 +362,6 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
|
|
360
362
|
<tr>
|
361
363
|
<td><code>GET</code></td>
|
362
364
|
<td>
|
363
|
-
|
364
365
|
<a href="https://app.myfinance.com.br/docs/api/categories#get_index" target="_blank">
|
365
366
|
/categories
|
366
367
|
</a>
|
@@ -567,6 +568,103 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
|
|
567
568
|
</tr>
|
568
569
|
</table>
|
569
570
|
|
571
|
+
#### [Webhooks](https://app.myfinance.com.br/docs/api/webhooks)
|
572
|
+
|
573
|
+
<table>
|
574
|
+
<tr>
|
575
|
+
<th>HTTP method</th>
|
576
|
+
<th>Endpoint</th>
|
577
|
+
<th>Client method</th>
|
578
|
+
</tr>
|
579
|
+
<tr>
|
580
|
+
<td><code>GET</code></td>
|
581
|
+
<td>
|
582
|
+
<a href="https://app.myfinance.com.br/docs/api/webhooks#get_index" target="_blank">
|
583
|
+
/integrations/webhooks
|
584
|
+
</a>
|
585
|
+
</td>
|
586
|
+
<td>
|
587
|
+
<code>client.webhooks.find_all</code>
|
588
|
+
</td>
|
589
|
+
</tr>
|
590
|
+
<tr>
|
591
|
+
<td><code>GET</code></td>
|
592
|
+
<td>
|
593
|
+
<a href="https://app.myfinance.com.br/docs/api/webhooks#get_show" target="_blank">
|
594
|
+
/integrations/webhooks/:id
|
595
|
+
</a>
|
596
|
+
</td>
|
597
|
+
<td>
|
598
|
+
<code>client.webhooks.find</code>
|
599
|
+
</td>
|
600
|
+
</tr>
|
601
|
+
<tr>
|
602
|
+
<td><code>POST</code></td>
|
603
|
+
<td>
|
604
|
+
<a href="https://app.myfinance.com.br/docs/api/webhooks#post_create" target="_blank">
|
605
|
+
/integrations/webhooks
|
606
|
+
</a>
|
607
|
+
</td>
|
608
|
+
<td>
|
609
|
+
<code>client.webhooks.create</code>
|
610
|
+
</td>
|
611
|
+
</tr>
|
612
|
+
<tr>
|
613
|
+
<td><code>PUT</code></td>
|
614
|
+
<td>
|
615
|
+
<a href="https://app.myfinance.com.br/docs/api/webhooks#put_update" target="_blank">
|
616
|
+
/integrations/webhooks/:id
|
617
|
+
</a>
|
618
|
+
</td>
|
619
|
+
<td>
|
620
|
+
<code>client.webhooks.update</code>
|
621
|
+
</td>
|
622
|
+
</tr>
|
623
|
+
<tr>
|
624
|
+
<td><code>DELETE</code></td>
|
625
|
+
<td>
|
626
|
+
<a href="https://app.myfinance.com.br/docs/api/webhooks#delete_destroy" target="_blank">
|
627
|
+
/integrations/webhooks/:id
|
628
|
+
</a>
|
629
|
+
</td>
|
630
|
+
<td>
|
631
|
+
<code>client.webhooks.destroy</code>
|
632
|
+
</td>
|
633
|
+
</tr>
|
634
|
+
</table>
|
635
|
+
|
636
|
+
#### [Taxes](https://app.myfinance.com.br/docs/api/taxes)
|
637
|
+
|
638
|
+
<table>
|
639
|
+
<tr>
|
640
|
+
<th>HTTP method</th>
|
641
|
+
<th>Endpoint</th>
|
642
|
+
<th>Client method</th>
|
643
|
+
</tr>
|
644
|
+
<tr>
|
645
|
+
<td><code>GET</code></td>
|
646
|
+
<td>
|
647
|
+
<a href="https://app.myfinance.com.br/docs/api/taxes#get_index" target="_blank">
|
648
|
+
/taxes
|
649
|
+
</a>
|
650
|
+
</td>
|
651
|
+
<td>
|
652
|
+
<code>client.taxes.find_all</code>
|
653
|
+
</td>
|
654
|
+
</tr>
|
655
|
+
<tr>
|
656
|
+
<td><code>GET</code></td>
|
657
|
+
<td>
|
658
|
+
<a href="https://app.myfinance.com.br/docs/api/taxes#get_show" target="_blank">
|
659
|
+
/taxes/:id
|
660
|
+
</a>
|
661
|
+
</td>
|
662
|
+
<td>
|
663
|
+
<code>client.taxes.find</code>
|
664
|
+
</td>
|
665
|
+
</tr>
|
666
|
+
</table>
|
667
|
+
|
570
668
|
### Configuration
|
571
669
|
|
572
670
|
```ruby
|
data/lib/myfinance.rb
CHANGED
@@ -26,6 +26,10 @@ require "myfinance/entities/deposit_account"
|
|
26
26
|
require "myfinance/entities/deposit_account_collection"
|
27
27
|
require "myfinance/entities/person"
|
28
28
|
require "myfinance/entities/person_collection"
|
29
|
+
require "myfinance/entities/webhook"
|
30
|
+
require "myfinance/entities/webhook_collection"
|
31
|
+
require "myfinance/entities/tax"
|
32
|
+
require "myfinance/entities/tax_collection"
|
29
33
|
|
30
34
|
require "myfinance/resources/base"
|
31
35
|
require "myfinance/resources/entity"
|
@@ -38,6 +42,8 @@ require "myfinance/resources/category"
|
|
38
42
|
require "myfinance/resources/account"
|
39
43
|
require "myfinance/resources/deposit_account"
|
40
44
|
require "myfinance/resources/person"
|
45
|
+
require "myfinance/resources/webhook"
|
46
|
+
require "myfinance/resources/tax"
|
41
47
|
|
42
48
|
module Myfinance
|
43
49
|
def self.configuration
|
data/lib/myfinance/client.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance classification center
|
5
|
+
#
|
6
|
+
class TaxCollection < Collection
|
7
|
+
def build_collection
|
8
|
+
response.parsed_body.each do |attributes|
|
9
|
+
collection.push(
|
10
|
+
Myfinance::Entities::Tax.new(
|
11
|
+
attributes["tax"]
|
12
|
+
)
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
class Webhook < Base
|
4
|
+
attribute :account_id, Integer
|
5
|
+
attribute :created_at, DateTime
|
6
|
+
attribute :description, String
|
7
|
+
attribute :entity_id, Integer
|
8
|
+
attribute :healthy_check_code, String
|
9
|
+
attribute :id, Integer
|
10
|
+
attribute :updated_at, DateTime
|
11
|
+
attribute :url, String
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Entities
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance webhook collection
|
5
|
+
#
|
6
|
+
class WebhookCollection < Collection
|
7
|
+
def build_collection
|
8
|
+
response.parsed_body.each do |attributes|
|
9
|
+
collection.push(
|
10
|
+
Myfinance::Entities::Webhook.new(attributes["webhook"])
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Resources
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance taxes API
|
5
|
+
#
|
6
|
+
# [API]
|
7
|
+
# Documentation: https://app.myfinance.com.br/docs/api/taxes
|
8
|
+
#
|
9
|
+
class Tax < Base
|
10
|
+
#
|
11
|
+
# List all taxes
|
12
|
+
#
|
13
|
+
# [API]
|
14
|
+
# Method: <tt>GET /taxes</tt>
|
15
|
+
#
|
16
|
+
# Documentation: https://app.myfinance.com.br/docs/api/taxes#get_index
|
17
|
+
#
|
18
|
+
def find_all
|
19
|
+
http.get("/taxes", body: {}) do |response|
|
20
|
+
respond_with_collection(response)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Show a tax
|
26
|
+
#
|
27
|
+
# [API]
|
28
|
+
# Method: <tt>GET /taxes/:id</tt>
|
29
|
+
#
|
30
|
+
# Documentation: https://app.myfinance.com.br/docs/api/taxes#get_show
|
31
|
+
#
|
32
|
+
def find(id)
|
33
|
+
http.get("/taxes/#{id}", body: {}) do |response|
|
34
|
+
respond_with_object(response, "tax")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Myfinance
|
2
|
+
module Resources
|
3
|
+
#
|
4
|
+
# A wrapper to Myfinance Webhooks API
|
5
|
+
#
|
6
|
+
# [API]
|
7
|
+
# Documentation: https://app.myfinance.com.br/docs/api/webhooks
|
8
|
+
#
|
9
|
+
class Webhook < Base
|
10
|
+
#
|
11
|
+
# List all webhooks
|
12
|
+
#
|
13
|
+
# [API]
|
14
|
+
# Method: <tt>GET /integrations/webhooks</tt>
|
15
|
+
#
|
16
|
+
# Documentation: https://app.myfinance.com.br/docs/api/webhooks#get_index
|
17
|
+
#
|
18
|
+
def find_all
|
19
|
+
http.get("/integrations/webhooks", body: {}) do |response|
|
20
|
+
respond_with_collection(response)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# List a webhook
|
26
|
+
#
|
27
|
+
# [API]
|
28
|
+
# Method: <tt>GET /integrations/webhooks/:id</tt>
|
29
|
+
#
|
30
|
+
# Documentation: https://app.myfinance.com.br/docs/api/webhooks#get_show
|
31
|
+
#
|
32
|
+
def find(id)
|
33
|
+
http.get("/integrations/webhooks/#{id}", body: {}) do |response|
|
34
|
+
respond_with_object response, "webhook"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Create a webhook
|
40
|
+
#
|
41
|
+
# [API]
|
42
|
+
# Method: <tt>POST /integrations/webhooks</tt>
|
43
|
+
#
|
44
|
+
# Documentation: https://app.myfinance.com.br/docs/api/webhooks#post_create
|
45
|
+
#
|
46
|
+
def create(params)
|
47
|
+
http.post("/integrations/webhooks", body: { webhook: params }) do |response|
|
48
|
+
respond_with_object(response, "webhook")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Updates a webhook
|
54
|
+
#
|
55
|
+
# [API]
|
56
|
+
# Method: <tt>PUT /integrations/webhooks/:id</tt>
|
57
|
+
#
|
58
|
+
# Documentation: https://app.myfinance.com.br/docs/api/webhooks#put_update
|
59
|
+
#
|
60
|
+
def update(id, params = {})
|
61
|
+
http.put(
|
62
|
+
"/integrations/webhooks/#{id}", body: { webhook: params }
|
63
|
+
) do |response|
|
64
|
+
respond_with_object(response, "webhook")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Destroy a webhook
|
70
|
+
#
|
71
|
+
# [API]
|
72
|
+
# Method: <tt>DELETE /integrations/webhooks/:id</tt>
|
73
|
+
#
|
74
|
+
# Documentation: https://app.myfinance.com.br/docs/api/webhooks#delete_destroy
|
75
|
+
#
|
76
|
+
def destroy(id)
|
77
|
+
http.delete("/integrations/webhooks/#{id}", body: {}) do |response|
|
78
|
+
respond_with_object(response, "webhook")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/myfinance/version.rb
CHANGED
@@ -100,4 +100,18 @@ describe Myfinance::Client do
|
|
100
100
|
subject.people
|
101
101
|
end
|
102
102
|
end
|
103
|
+
|
104
|
+
describe "#webhooks" do
|
105
|
+
it "instantiates a new Myfinance::Resources::Webhook" do
|
106
|
+
expect(Myfinance::Resources::Webhook).to receive(:new).with(subject.http)
|
107
|
+
subject.webhooks
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#taxes" do
|
112
|
+
it "instantiates a new Myfinance::Resources::Tax" do
|
113
|
+
expect(Myfinance::Resources::Tax).to receive(:new).with(subject.http)
|
114
|
+
subject.taxes
|
115
|
+
end
|
116
|
+
end
|
103
117
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Myfinance::Entities::TaxCollection do
|
4
|
+
let(:entity_klass) { described_class }
|
5
|
+
|
6
|
+
let(:params) { double(headers: {}, parsed_body: [{}]) }
|
7
|
+
|
8
|
+
subject { described_class.new(params) }
|
9
|
+
|
10
|
+
context "#build" do
|
11
|
+
it "returns order collection" do
|
12
|
+
expect(subject.build).to be_a(entity_klass)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns order" do
|
16
|
+
subject.build
|
17
|
+
expect(subject.collection.count).to eq(1)
|
18
|
+
expect(
|
19
|
+
subject.collection.first
|
20
|
+
).to be_a(Myfinance::Entities::Tax)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Myfinance::Entities::WebhookCollection do
|
4
|
+
let(:response) do
|
5
|
+
double(
|
6
|
+
headers: {},
|
7
|
+
parsed_body: [
|
8
|
+
{
|
9
|
+
"webhook" => {
|
10
|
+
"account_id" => 3613,
|
11
|
+
"created_at" => "2015-09-21T15:41:05-03:00",
|
12
|
+
"description" => "Webhook test",
|
13
|
+
"entity_id" => 3798,
|
14
|
+
"healthy_check_code" => "200",
|
15
|
+
"id" => 76,
|
16
|
+
"updated_at" => "2015-09-21T16:08:48-03:00",
|
17
|
+
"url" => "https://sandbox.myfinance.com.br/docs/api/webhooks"
|
18
|
+
}
|
19
|
+
},{
|
20
|
+
"webhook" => {
|
21
|
+
"account_id" => 3613,
|
22
|
+
"created_at" => "2015-09-21T16:15:22-03:00",
|
23
|
+
"description" => "Webhook 1",
|
24
|
+
"entity_id" => 3798,
|
25
|
+
"healthy_check_code" => "200",
|
26
|
+
"id" => 77,
|
27
|
+
"updated_at" => "2015-09-21T16:15:35-03:00",
|
28
|
+
"url" => "https://sandbox.myfinance.com.br/docs/api/webhooks"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
]
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
subject { Myfinance::Entities::WebhookCollection.new(response) }
|
36
|
+
|
37
|
+
describe "#build" do
|
38
|
+
it "returns order collection" do
|
39
|
+
expect(subject.build).to be_a(Myfinance::Entities::WebhookCollection)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns order" do
|
43
|
+
subject.build
|
44
|
+
expect(subject.collection.count).to eq(2)
|
45
|
+
expect(subject.collection.first).to be_a(Myfinance::Entities::Webhook)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Myfinance::Resources::Tax, vcr: true do
|
4
|
+
let(:klass) { Myfinance::Entities::Tax }
|
5
|
+
|
6
|
+
let(:collection) do
|
7
|
+
Myfinance::Entities::TaxCollection
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#find_all" do
|
11
|
+
context "when success" do
|
12
|
+
subject { client.taxes.find_all }
|
13
|
+
|
14
|
+
it "show all taxes" do
|
15
|
+
expect(subject).to be_a(collection)
|
16
|
+
expect(subject.collection.first).to be_a(klass)
|
17
|
+
expect(subject.collection.first.name).to eq("Outros")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when error" do
|
22
|
+
let(:client) { Myfinance.client("") }
|
23
|
+
|
24
|
+
it "raises Myfinance::RequestError with 401 status code" do
|
25
|
+
expect { client.taxes.find_all }.to raise_error(Myfinance::RequestError) do |error|
|
26
|
+
expect(error.code).to eq(401)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#find" do
|
33
|
+
context "when success" do
|
34
|
+
subject { client.taxes.find(1) }
|
35
|
+
|
36
|
+
it "show a tax successfully" do
|
37
|
+
expect(subject).to be_a(klass)
|
38
|
+
expect(subject.name).to eq("Outros")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when error" do
|
43
|
+
it "raises Myfinance::RequestError with 404 status code" do
|
44
|
+
expect { client.taxes.find(42424242) }.to raise_error(Myfinance::RequestError) do |error|
|
45
|
+
expect(error.code).to eq(404)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Myfinance::Resources::Webhook, vcr: true do
|
4
|
+
let(:entity_klass) { Myfinance::Entities::Webhook }
|
5
|
+
|
6
|
+
describe "#find_all" do
|
7
|
+
context "when success" do
|
8
|
+
subject { client.webhooks.find_all }
|
9
|
+
|
10
|
+
it "show all webhooks successfully" do
|
11
|
+
expect(subject.class).to eq(Myfinance::Entities::WebhookCollection)
|
12
|
+
expect(subject.collection.first.description).to eq("Webhook test")
|
13
|
+
expect(subject.collection.first.id).to eq(76)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when error" do
|
18
|
+
let(:client) { Myfinance.client("") }
|
19
|
+
|
20
|
+
it "raises Myfinance::RequestError with 401 status code" do
|
21
|
+
expect {
|
22
|
+
client.webhooks.find_all
|
23
|
+
}.to raise_error(Myfinance::RequestError) do |error|
|
24
|
+
expect(error.code).to eq(401)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#find" do
|
31
|
+
context "when success" do
|
32
|
+
subject { client.webhooks.find(76) }
|
33
|
+
|
34
|
+
it "find a webhook successfully" do
|
35
|
+
expect(subject).to be_a(entity_klass)
|
36
|
+
expect(subject.id).to eq(76)
|
37
|
+
expect(subject.description).to eq("Webhook test")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when error" do
|
42
|
+
it "raises Myfinance::RequestError with 404 status code" do
|
43
|
+
expect {
|
44
|
+
client.webhooks.find(888888)
|
45
|
+
}.to raise_error(Myfinance::RequestError) do |error|
|
46
|
+
expect(error.code).to eq(404)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#create" do
|
53
|
+
context "when success" do
|
54
|
+
let(:params) do
|
55
|
+
{
|
56
|
+
entity_id: 3798,
|
57
|
+
description: "Webhook 2",
|
58
|
+
url: "https://sandbox.myfinance.com.br/docs/api/webhooks#get_show",
|
59
|
+
format: "json"
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
it "creates a webhook successfully" do
|
64
|
+
result = client.webhooks.create(params)
|
65
|
+
expect(result).to be_a(entity_klass)
|
66
|
+
expect(result.description).to eq("Webhook 2")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when error" do
|
71
|
+
it "raises Myfinance::RequestError with 422 status code" do
|
72
|
+
expect {
|
73
|
+
client.webhooks.create({ description: "" })
|
74
|
+
}.to raise_error(Myfinance::RequestError) do |error|
|
75
|
+
expect(error.code).to eq(422)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#update" do
|
82
|
+
context "when success" do
|
83
|
+
let(:params) { { description: "Description updated" } }
|
84
|
+
|
85
|
+
it "updates a webhook successfully" do
|
86
|
+
result = client.webhooks.update(76, params)
|
87
|
+
expect(result).to be_a(entity_klass)
|
88
|
+
expect(result.description).to eq("Description updated")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "when error" do
|
93
|
+
it "raises Myfinance::RequestError with 422 status code" do
|
94
|
+
expect {
|
95
|
+
client.webhooks.update(76, { url: "" })
|
96
|
+
}.to raise_error(Myfinance::RequestError) do |error|
|
97
|
+
expect(error.code).to eq(422)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#destroy" do
|
104
|
+
context "when success" do
|
105
|
+
it "destroy a webhook successfully" do
|
106
|
+
expect(client.webhooks.destroy(77)).to be_truthy
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "when error" do
|
111
|
+
it "raises Myfinance::RequestError with 404 status code" do
|
112
|
+
expect {
|
113
|
+
client.webhooks.destroy(888888)
|
114
|
+
}.to raise_error(Myfinance::RequestError) do |error|
|
115
|
+
expect(error.code).to eq(404)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myfinance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Hertz
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-03-
|
14
|
+
date: 2017-03-14 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: typhoeus
|
@@ -257,6 +257,10 @@ files:
|
|
257
257
|
- lib/myfinance/entities/person.rb
|
258
258
|
- lib/myfinance/entities/person_collection.rb
|
259
259
|
- lib/myfinance/entities/receivable_account.rb
|
260
|
+
- lib/myfinance/entities/tax.rb
|
261
|
+
- lib/myfinance/entities/tax_collection.rb
|
262
|
+
- lib/myfinance/entities/webhook.rb
|
263
|
+
- lib/myfinance/entities/webhook_collection.rb
|
260
264
|
- lib/myfinance/exception.rb
|
261
265
|
- lib/myfinance/http.rb
|
262
266
|
- lib/myfinance/request.rb
|
@@ -271,6 +275,8 @@ files:
|
|
271
275
|
- lib/myfinance/resources/payable_account.rb
|
272
276
|
- lib/myfinance/resources/person.rb
|
273
277
|
- lib/myfinance/resources/receivable_account.rb
|
278
|
+
- lib/myfinance/resources/tax.rb
|
279
|
+
- lib/myfinance/resources/webhook.rb
|
274
280
|
- lib/myfinance/response.rb
|
275
281
|
- lib/myfinance/version.rb
|
276
282
|
- myfinance.gemspec
|
@@ -294,6 +300,10 @@ files:
|
|
294
300
|
- spec/lib/myfinance/entities/person_collection_spec.rb
|
295
301
|
- spec/lib/myfinance/entities/person_spec.rb
|
296
302
|
- spec/lib/myfinance/entities/receivable_account_spec.rb
|
303
|
+
- spec/lib/myfinance/entities/tax_collection_spec.rb
|
304
|
+
- spec/lib/myfinance/entities/tax_spec.rb
|
305
|
+
- spec/lib/myfinance/entities/webhook_collection_spec.rb
|
306
|
+
- spec/lib/myfinance/entities/webhook_spec.rb
|
297
307
|
- spec/lib/myfinance/http_spec.rb
|
298
308
|
- spec/lib/myfinance/request_spec.rb
|
299
309
|
- spec/lib/myfinance/resources/account_spec.rb
|
@@ -305,6 +315,8 @@ files:
|
|
305
315
|
- spec/lib/myfinance/resources/payable_account_spec.rb
|
306
316
|
- spec/lib/myfinance/resources/person_spec.rb
|
307
317
|
- spec/lib/myfinance/resources/receivable_account_spec.rb
|
318
|
+
- spec/lib/myfinance/resources/tax_spec.rb
|
319
|
+
- spec/lib/myfinance/resources/webhook_spec.rb
|
308
320
|
- spec/lib/myfinance/response_spec.rb
|
309
321
|
- spec/lib/myfinance_spec.rb
|
310
322
|
- spec/spec_helper.rb
|
@@ -360,6 +372,10 @@ test_files:
|
|
360
372
|
- spec/lib/myfinance/entities/person_collection_spec.rb
|
361
373
|
- spec/lib/myfinance/entities/person_spec.rb
|
362
374
|
- spec/lib/myfinance/entities/receivable_account_spec.rb
|
375
|
+
- spec/lib/myfinance/entities/tax_collection_spec.rb
|
376
|
+
- spec/lib/myfinance/entities/tax_spec.rb
|
377
|
+
- spec/lib/myfinance/entities/webhook_collection_spec.rb
|
378
|
+
- spec/lib/myfinance/entities/webhook_spec.rb
|
363
379
|
- spec/lib/myfinance/http_spec.rb
|
364
380
|
- spec/lib/myfinance/request_spec.rb
|
365
381
|
- spec/lib/myfinance/resources/account_spec.rb
|
@@ -371,6 +387,8 @@ test_files:
|
|
371
387
|
- spec/lib/myfinance/resources/payable_account_spec.rb
|
372
388
|
- spec/lib/myfinance/resources/person_spec.rb
|
373
389
|
- spec/lib/myfinance/resources/receivable_account_spec.rb
|
390
|
+
- spec/lib/myfinance/resources/tax_spec.rb
|
391
|
+
- spec/lib/myfinance/resources/webhook_spec.rb
|
374
392
|
- spec/lib/myfinance/response_spec.rb
|
375
393
|
- spec/lib/myfinance_spec.rb
|
376
394
|
- spec/spec_helper.rb
|