billimatic-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +7 -0
  3. data/.gitignore +41 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +11 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.lock +120 -0
  8. data/Guardfile +70 -0
  9. data/LICENSE +21 -0
  10. data/README.md +184 -0
  11. data/Rakefile +9 -0
  12. data/billimatic-client-ruby.gemspec +43 -0
  13. data/bin/console +14 -0
  14. data/bin/setup +7 -0
  15. data/lib/billimatic.rb +53 -0
  16. data/lib/billimatic/client.rb +47 -0
  17. data/lib/billimatic/configuration.rb +12 -0
  18. data/lib/billimatic/entities/address_information.rb +15 -0
  19. data/lib/billimatic/entities/base.rb +9 -0
  20. data/lib/billimatic/entities/company.rb +25 -0
  21. data/lib/billimatic/entities/contract.rb +25 -0
  22. data/lib/billimatic/entities/customer.rb +12 -0
  23. data/lib/billimatic/entities/entity_service_item.rb +11 -0
  24. data/lib/billimatic/entities/invoice.rb +8 -0
  25. data/lib/billimatic/entities/invoice_rule.rb +8 -0
  26. data/lib/billimatic/entities/plan.rb +21 -0
  27. data/lib/billimatic/entities/product.rb +6 -0
  28. data/lib/billimatic/entities/subscription.rb +6 -0
  29. data/lib/billimatic/entities/webhook.rb +8 -0
  30. data/lib/billimatic/exception.rb +11 -0
  31. data/lib/billimatic/http.rb +32 -0
  32. data/lib/billimatic/request.rb +51 -0
  33. data/lib/billimatic/resources/base.rb +116 -0
  34. data/lib/billimatic/resources/company.rb +26 -0
  35. data/lib/billimatic/resources/contract.rb +10 -0
  36. data/lib/billimatic/resources/hooks.rb +25 -0
  37. data/lib/billimatic/resources/invoice.rb +11 -0
  38. data/lib/billimatic/resources/invoice_rule.rb +10 -0
  39. data/lib/billimatic/resources/plan.rb +11 -0
  40. data/lib/billimatic/resources/subscription.rb +19 -0
  41. data/lib/billimatic/resources/webhook.rb +10 -0
  42. data/lib/billimatic/response.rb +32 -0
  43. data/lib/billimatic/signature.rb +14 -0
  44. data/lib/billimatic/version.rb +3 -0
  45. metadata +272 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9532f216c2df6e26a862a6f2fc69467f71cc3e11
4
+ data.tar.gz: 4ccc394a07225e14d6771c273817484f5863a1c7
5
+ SHA512:
6
+ metadata.gz: 878280c8f5ca6466ffb854d401790b6deae8af6b3f4701f2bc0b2325b5239549b230fe1a34a8de12002783219b9a608a648199f3776d8dfd886466b187ba58fe
7
+ data.tar.gz: a75c209d9530d8bcfa7640680e666003e8b7993bd9782af5ef76b6761be44586fabdd01c53933eb12ce13c176dbe894108b6876c1bdd0d159c1cdb052cd5227e
data/.codeclimate.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ engines:
3
+ fixme:
4
+ enabled: true
5
+ ratings:
6
+ paths: []
7
+ exclude_paths: []
data/.gitignore ADDED
@@ -0,0 +1,41 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalization:
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ # Gemfile.lock
32
+ .ruby-version
33
+ .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
37
+
38
+ .env
39
+ .envrc
40
+
41
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.8
4
+ - 2.2.4
5
+ - 2.3.0
6
+ env:
7
+ global:
8
+ # CODECLIMATE_REPO_TOKEN
9
+ - secure: "EQVwKIRe3wcDIVOhHNzXpkGuPeadGezOGgm0HIvXCkx6P8+QYNkTVbFoWWEoiDI388mLbIWqi4TePlYe0/HBkXNOZnyHuTeCn/juWELKVwpNPPQdWCuyQocxyXhfax3FBGNwybNu2wy+jWSGoU789Jhf2oVGgKMgaZfjZyoj/zSszla4bSzUk6RWJH8vu2u0uhjaZtlgz/Z13DpEBxBgOUcpx4AcTHjKKmUFmU6i/q0ZVcc2RW8igZcqgMyMMP2sXQ+GV/BVM7wJfFIKM1/7r6ZHK7cu6rxKdEpEAailHJzUGXfFxMR2xLr9PJxvJx1CumP/9ofHsE1BErL1O+BpsDf0sG+tAFcuXCJB5Twvtd4U9gmlFlsp8WY/aINm5kBDtLaPz1pmJucKRYfwBAWiBMlJzSu3rzM0leNsvgkRUvmoGw3fkurNrPr4QI8XG50+zfQYKXJ0SA8LsGtky2+Gm8MOQ5PkWFtrs+RQCpWHWKHlVNe0Dt6yG/U6PbrrIyTngyfIVob7qwMgTC3m72JiDNw5zTW95d6x2dZDlCYTiRvVoppOHIlo+MrWVRxeYEOH1pT9nZiJx2eH7n1V/HsOdInUyywVhtm/ypUDRqX/Qe5Wx0jQOXxZD3XdqVKQuQcvTA0MsDy3FvnxRKy0s94iv2aL6PeQtySkUKrjsd7gT9k="
10
+ script:
11
+ - bundle exec rake --trace spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in billimatic-client-ruby.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,120 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ billimatic-client (0.0.1)
5
+ multi_json (~> 1.11.2)
6
+ typhoeus (~> 1.0.1)
7
+ virtus (~> 1.0.5)
8
+ wisper (~> 1.6.1)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ axiom-types (0.1.1)
14
+ descendants_tracker (~> 0.0.4)
15
+ ice_nine (~> 0.11.0)
16
+ thread_safe (~> 0.3, >= 0.3.1)
17
+ byebug (8.2.4)
18
+ codeclimate-test-reporter (0.5.0)
19
+ simplecov (>= 0.7.1, < 1.0.0)
20
+ coderay (1.1.1)
21
+ coercible (1.0.0)
22
+ descendants_tracker (~> 0.0.1)
23
+ descendants_tracker (0.0.4)
24
+ thread_safe (~> 0.3, >= 0.3.1)
25
+ diff-lcs (1.2.5)
26
+ docile (1.1.5)
27
+ equalizer (0.0.11)
28
+ ethon (0.8.1)
29
+ ffi (>= 1.3.0)
30
+ ffi (1.9.10)
31
+ formatador (0.2.5)
32
+ guard (2.13.0)
33
+ formatador (>= 0.2.4)
34
+ listen (>= 2.7, <= 4.0)
35
+ lumberjack (~> 1.0)
36
+ nenv (~> 0.1)
37
+ notiffany (~> 0.0)
38
+ pry (>= 0.9.12)
39
+ shellany (~> 0.0)
40
+ thor (>= 0.18.1)
41
+ guard-compat (1.2.1)
42
+ guard-rspec (4.6.5)
43
+ guard (~> 2.1)
44
+ guard-compat (~> 1.1)
45
+ rspec (>= 2.99.0, < 4.0)
46
+ ice_nine (0.11.2)
47
+ json (1.8.3)
48
+ listen (3.0.6)
49
+ rb-fsevent (>= 0.9.3)
50
+ rb-inotify (>= 0.9.7)
51
+ lumberjack (1.0.10)
52
+ method_source (0.8.2)
53
+ multi_json (1.11.2)
54
+ nenv (0.3.0)
55
+ notiffany (0.0.8)
56
+ nenv (~> 0.1)
57
+ shellany (~> 0.0)
58
+ notifier (0.5.1)
59
+ pry (0.10.3)
60
+ coderay (~> 1.1.0)
61
+ method_source (~> 0.8.1)
62
+ slop (~> 3.4)
63
+ pry-byebug (3.3.0)
64
+ byebug (~> 8.0)
65
+ pry (~> 0.10)
66
+ rake (11.1.2)
67
+ rb-fsevent (0.9.7)
68
+ rb-inotify (0.9.7)
69
+ ffi (>= 0.5.0)
70
+ rspec (3.4.0)
71
+ rspec-core (~> 3.4.0)
72
+ rspec-expectations (~> 3.4.0)
73
+ rspec-mocks (~> 3.4.0)
74
+ rspec-core (3.4.4)
75
+ rspec-support (~> 3.4.0)
76
+ rspec-expectations (3.4.0)
77
+ diff-lcs (>= 1.2.0, < 2.0)
78
+ rspec-support (~> 3.4.0)
79
+ rspec-mocks (3.4.1)
80
+ diff-lcs (>= 1.2.0, < 2.0)
81
+ rspec-support (~> 3.4.0)
82
+ rspec-support (3.4.1)
83
+ shellany (0.0.1)
84
+ simplecov (0.11.2)
85
+ docile (~> 1.1.0)
86
+ json (~> 1.8)
87
+ simplecov-html (~> 0.10.0)
88
+ simplecov-html (0.10.0)
89
+ slop (3.6.0)
90
+ test_notifier (2.0.3)
91
+ notifier
92
+ thor (0.19.1)
93
+ thread_safe (0.3.5)
94
+ typhoeus (1.0.1)
95
+ ethon (>= 0.8.0)
96
+ vcr (3.0.1)
97
+ virtus (1.0.5)
98
+ axiom-types (~> 0.1)
99
+ coercible (~> 1.0)
100
+ descendants_tracker (~> 0.0, >= 0.0.3)
101
+ equalizer (~> 0.0, >= 0.0.9)
102
+ wisper (1.6.1)
103
+
104
+ PLATFORMS
105
+ ruby
106
+
107
+ DEPENDENCIES
108
+ billimatic-client!
109
+ bundler (~> 1.11)
110
+ codeclimate-test-reporter (~> 0.5)
111
+ guard-rspec (~> 4.6)
112
+ pry-byebug (~> 3.3)
113
+ rake (~> 11.1)
114
+ rspec (~> 3.4)
115
+ simplecov (~> 0.11)
116
+ test_notifier (~> 2.0)
117
+ vcr (~> 3.0)
118
+
119
+ BUNDLED WITH
120
+ 1.11.2
data/Guardfile ADDED
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # # Rails files
44
+ # rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ # dsl.watch_spec_files_for(rails.app_files)
46
+ # dsl.watch_spec_files_for(rails.views)
47
+
48
+ # watch(rails.controllers) do |m|
49
+ # [
50
+ # rspec.spec.("routing/#{m[1]}_routing"),
51
+ # rspec.spec.("controllers/#{m[1]}_controller"),
52
+ # rspec.spec.("acceptance/#{m[1]}")
53
+ # ]
54
+ # end
55
+
56
+ # # Rails config changes
57
+ # watch(rails.spec_helper) { rspec.spec_dir }
58
+ # watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ # watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # # Capybara features specs
62
+ # watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
63
+ # watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Myfreecomm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # Billimatic API Ruby Client
2
+
3
+ This is the official Ruby client for the [Billimatic](http://www.billimatic.com.br) API.
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/billimatic-client.png)](https://rubygems.org/gems/billimatic-client)
6
+ [![Build Status](https://api.travis-ci.org/myfreecomm/billimatic-client-ruby.svg?branch=master)](https://travis-ci.org/myfreecomm/billimatic-client-ruby)
7
+ [![Test Coverage](https://codeclimate.com/github/myfreecomm/billimatic-client-ruby/badges/coverage.svg)](https://codeclimate.com/github/myfreecomm/billimatic-client-ruby/coverage)
8
+ [![Code Climate Grade](https://codeclimate.com/github/myfreecomm/billimatic-client-ruby/badges/gpa.svg)](https://codeclimate.com/github/myfreecomm/billimatic-client-ruby)
9
+ [![Inline docs](http://inch-ci.org/github/myfreecomm/billimatic-client-ruby.svg?branch=master)](http://inch-ci.org/github/myfreecomm/billimatic-client-ruby)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'billimatic-client'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install billimatic-client
26
+
27
+ ## Configuration
28
+
29
+ ##### Use Billimatic.configure to setup your environment:
30
+
31
+ ```ruby
32
+ require 'billimatic'
33
+
34
+ Billimatic.configure do |config|
35
+ config.url = 'https://sandbox.billimatic.com.br/api/v1' # defaults to 'https://app.billimatic.com.br/api/v1'
36
+ config.user_agent = 'My App v1.0' # optional, but you should pass a custom user-agent identifying your app
37
+ end
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ##### Given your token, create an instance of Billimatic::Client, as below:
43
+
44
+ ```ruby
45
+ client = Billimatic.client("YOUR_TOKEN_HERE")
46
+ ```
47
+
48
+ ##### Now you have acess to every API endpoint:
49
+
50
+ * [Companies API](https://app.billimatic.com.br/docs/api#!/companies) as `client.companies`
51
+ * [Plans API](https://app.billimatic.com.br/docs/api#!/plans) as `client.plans`
52
+ * [Subscriptions API](https://app.billimatic.com.br/docs/api#!/subscriptions) as `client.subscriptions`
53
+
54
+ ## Endpoints
55
+
56
+ #### [Companies](https://app.billimatic.com.br/docs/api#!/companies)
57
+
58
+ <table>
59
+ <tr>
60
+ <th>HTTP method</th>
61
+ <th>Endpoint</th>
62
+ <th>Client method</th>
63
+ </tr>
64
+ <tr>
65
+ <td><code>GET</code></td>
66
+ <td>
67
+ <a href="https://app.billimatic.com.br/docs/api#!/companies/API_V1_Companies_search_get_0" target="_blank">
68
+ /api/v1/companies/search?cnpj=:cnpj
69
+ </a>
70
+ </td>
71
+ <td>
72
+ <code>client.companies.search(cnpj)</code>
73
+ </td>
74
+ </tr>
75
+ <tr>
76
+ <td><code>POST</code></td>
77
+ <td>
78
+ <a href="https://app.billimatic.com.br/docs/api#!/companies/API_V1_Companies_create_post_1" target="_blank">
79
+ /api/v1/companies
80
+ </a>
81
+ </td>
82
+ <td>
83
+ <code>client.companies.create(attributes_hash)</code>
84
+ </td>
85
+ </tr>
86
+ <tr>
87
+ <td><code>PATCH</code></td>
88
+ <td>
89
+ <a href="https://app.billimatic.com.br/docs/api#!/companies/API_V1_Companies_update_patch_2" target="_blank">
90
+ /api/v1/companies/:id
91
+ </a>
92
+ </td>
93
+ <td>
94
+ <code>client.companies.update(id, attributes_hash)</code>
95
+ </td>
96
+ </tr>
97
+ <tr>
98
+ <td><code>DELETE</code></td>
99
+ <td>
100
+ <a href="https://app.billimatic.com.br/docs/api#!/companies/API_V1_Companies_destroy_delete_3" target="_blank">
101
+ /api/v1/companies/:id
102
+ </a>
103
+ </td>
104
+ <td>
105
+ <code>client.companies.destroy(id)</code>
106
+ </td>
107
+ </tr>
108
+ </table>
109
+
110
+ #### [Plans](https://app.billimatic.com.br/docs/api#!/plans)
111
+
112
+ <table>
113
+ <tr>
114
+ <th>HTTP method</th>
115
+ <th>Endpoint</th>
116
+ <th>Client method</th>
117
+ </tr>
118
+ <tr>
119
+ <td><code>GET</code></td>
120
+ <td>
121
+ <a href="https://app.billimatic.com.br/docs/api#!/plans/API_V1_Plans_index_get_0" target="_blank">
122
+ /api/v1/organizations/:organization_id/plans
123
+ </a>
124
+ </td>
125
+ <td>
126
+ <code>client.plans.list(organization_id: id)</code>
127
+ </td>
128
+ </tr>
129
+ </table>
130
+
131
+ #### [Subscriptions](https://app.billimatic.com.br/docs/api#!/subscriptions)
132
+
133
+ <table>
134
+ <tr>
135
+ <th>HTTP method</th>
136
+ <th>Endpoint</th>
137
+ <th>Client method</th>
138
+ </tr>
139
+ <tr>
140
+ <td><code>GET</code></td>
141
+ <td>
142
+ <a href="https://app.billimatic.com.br/docs/api#!/subscriptions/API_V1_Subscriptions_show_by_token_get_1" target="_blank">
143
+ /api/v1/subscriptions/token/:token
144
+ </a>
145
+ </td>
146
+ <td>
147
+ <code>client.subscriptions.show(token: token)</code>
148
+ </td>
149
+ </tr>
150
+ <tr>
151
+ <td><code>POST</code></td>
152
+ <td>
153
+ <a href="https://app.billimatic.com.br/docs/api#!/subscriptions/API_V1_Subscriptions_create_post_2" target="_blank">
154
+ /api/v1/subscriptions
155
+ </a>
156
+ </td>
157
+ <td>
158
+ <code>client.subscriptions.create(attributes_hash)</code>
159
+ </td>
160
+ </tr>
161
+ <tr>
162
+ <td><code>PATCH</code></td>
163
+ <td>
164
+ <a href="https://app.billimatic.com.br/docs/api#!/subscriptions/API_V1_Subscriptions_cancel_patch_0" target="_blank">
165
+ /api/v1/subscriptions/:token/cancel
166
+ </a>
167
+ </td>
168
+ <td>
169
+ <code>client.subscriptions.cancel(token: token)</code>
170
+ </td>
171
+ </tr>
172
+ </table>
173
+
174
+ ## Callbacks
175
+
176
+ TODO
177
+
178
+ ## Contributing
179
+
180
+ 1. Fork it ( https://github.com/[my-github-username]/billimatic-client-ruby/fork )
181
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
182
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
183
+ 4. Push to the branch (`git push origin my-new-feature`)
184
+ 5. Create a new Pull Request