vpsa 0.0.1
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 +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +16 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +77 -0
- data/Rakefile +10 -0
- data/lib/vpsa.rb +36 -0
- data/lib/vpsa/api/default_entries.rb +20 -0
- data/lib/vpsa/api/entities.rb +20 -0
- data/lib/vpsa/api/provisions.rb +11 -0
- data/lib/vpsa/api/third_parties.rb +20 -0
- data/lib/vpsa/client.rb +65 -0
- data/lib/vpsa/entity/base.rb +19 -0
- data/lib/vpsa/init_from_hash.rb +9 -0
- data/lib/vpsa/searcher/administrative/entity_searcher.rb +11 -0
- data/lib/vpsa/searcher/administrative/third_party_searcher.rb +11 -0
- data/lib/vpsa/searcher/base.rb +21 -0
- data/lib/vpsa/searcher/financial/default_entry_searcher.rb +11 -0
- data/lib/vpsa/version.rb +3 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/vpsa/api/default_entries_spec.rb +41 -0
- data/spec/vpsa/api/entities_spec.rb +41 -0
- data/spec/vpsa/api/provisions_spec.rb +19 -0
- data/spec/vpsa/api/third_parties_spec.rb +41 -0
- data/spec/vpsa/client_spec.rb +19 -0
- data/spec/vpsa_spec.rb +7 -0
- data/vpsa.gemspec +23 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2581e6b2cdc9efced4649c51b61371830699181b
|
4
|
+
data.tar.gz: 7981e944fedbcec6c9ff819892fccd91afc8e5bb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e1773d21003f1db07315779909f370dc6384df13bad48d53e4ec4e46138948c127e6b11cca93ab10910a12d247556fd778ba4bb9638b2a7bb42081f197208658
|
7
|
+
data.tar.gz: 687cdff259911bf1512a10c1849e8cde3e08c89997572a935eb4c6caa05e67c96c21216828f5308e4d9b5b1cbafba304fffce0fd20cb818a80398761e8158dc8
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0.0
|
4
|
+
|
5
|
+
addons:
|
6
|
+
code_climate:
|
7
|
+
repo_token: 792ab6282add3c34a98e894466e2a54e9d66516512d73ebefe8dfa73446a5cee
|
8
|
+
|
9
|
+
bundler_args: --without development
|
10
|
+
|
11
|
+
notifications:
|
12
|
+
email:
|
13
|
+
recipients:
|
14
|
+
- gberdugo@gmail.com
|
15
|
+
on_failure: change
|
16
|
+
on_success: never
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in vpsa.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'debugger', :group => :development
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem "rspec", "~> 3.1"
|
10
|
+
gem "rake", "~> 10.3"
|
11
|
+
gem "webmock", "~> 1.20"
|
12
|
+
gem "codeclimate-test-reporter", "~> 0.4"
|
13
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Coyô Software
|
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.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# VPSA
|
2
|
+
|
3
|
+
[](https://travis-ci.org/coyosoftware/vpsa) [](http://badge.fury.io/rb/vpsa) [](https://codeclimate.com/github/coyosoftware/vpsa) [](https://codeclimate.com/github/coyosoftware/vpsa)
|
4
|
+
|
5
|
+
This gem simplifies the usage of [VPSA](http://www.vpsa.com.br/) API
|
6
|
+
|
7
|
+
For more information regarding the API, visit the [documentation]
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'vpsa'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install vpsa
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Create a new instance of VPSA class passing your access token:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
client = Vpsa.new(YOUR_ACCESS_TOKEN)
|
29
|
+
```
|
30
|
+
|
31
|
+
With the client instance, you can access the following resources:
|
32
|
+
|
33
|
+
* Terceiros (client.third_parties) **Listing and finding**
|
34
|
+
* Entidades (client.entities) **Listing and finding**
|
35
|
+
* Lançamentos Padrões (client.default_entries) **Listing and finding**
|
36
|
+
|
37
|
+
## Using the resources
|
38
|
+
### Listing
|
39
|
+
All resources implement a **list** method.
|
40
|
+
|
41
|
+
It can accept an Entity object that reflects the searchable API fields.
|
42
|
+
|
43
|
+
Currently the following entities are implemented:
|
44
|
+
|
45
|
+
* [Terceiros](lib/vpsa/searcher/administrative/third_party_searcher.rb)
|
46
|
+
* [Entidades](lib/vpsa/searcher/administrative/entity_searcher.rb)
|
47
|
+
* [Lançamentos Padrões](lib/vpsa/searcher/financial/default_entry_searcher.rb)
|
48
|
+
|
49
|
+
### Finding
|
50
|
+
All resources implement a **find** method.
|
51
|
+
|
52
|
+
It finds the resource with the passed ID.
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
Vpsa.new(YOUR_ACCESS_TOKEN).third_parties.find(4)
|
56
|
+
```
|
57
|
+
|
58
|
+
### Reading the response
|
59
|
+
All methods return an Vpsa::Client::Response object. This objects contains the following attributes:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
response = Vpsa.new(YOUR_ACCESS_TOKEN).third_parties.list
|
63
|
+
|
64
|
+
response.status # Contains the status code of the request
|
65
|
+
response.payload # Contains the return data (JSON) of the request
|
66
|
+
response.raw_response # Contains the HTTParty response object
|
67
|
+
```
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
|
71
|
+
1. Fork it ( https://github.com/coyosoftware/vpsa/fork )
|
72
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
73
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
74
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
75
|
+
5. Create a new Pull Request
|
76
|
+
|
77
|
+
[documentation]: https://github.com/VPSA/api/wiki/
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
# Default directory to look in is `/specs`
|
5
|
+
# Run with `rake spec`
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
7
|
+
task.rspec_opts = ['--color', '--format', 'documentation']
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :spec
|
data/lib/vpsa.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "vpsa/version"
|
2
|
+
|
3
|
+
module Vpsa
|
4
|
+
LIBNAME = 'vpsa'
|
5
|
+
LIBDIR = File.expand_path("../#{LIBNAME}", __FILE__)
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def included(base)
|
9
|
+
base.extend ClassMethods
|
10
|
+
end
|
11
|
+
|
12
|
+
def new(access_token)
|
13
|
+
Client.new(access_token)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
# Requires internal libraries
|
19
|
+
#
|
20
|
+
# @param [String] prefix
|
21
|
+
# the relative path prefix
|
22
|
+
# @param [Array[String]] libs
|
23
|
+
# the array of libraries to require
|
24
|
+
#
|
25
|
+
# @return [self]
|
26
|
+
def require_all(prefix, *libs)
|
27
|
+
libs.each do |lib|
|
28
|
+
require "#{File.join(prefix, lib)}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
extend ClassMethods
|
34
|
+
|
35
|
+
require_all LIBDIR, 'client'
|
36
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Vpsa
|
2
|
+
module Api
|
3
|
+
class DefaultEntries < Client
|
4
|
+
require_all 'vpsa/searcher/financial', 'default_entry_searcher'
|
5
|
+
|
6
|
+
base_uri "https://www.vpsa.com.br/apps/api/lancamentos-padroes"
|
7
|
+
|
8
|
+
def list(searcher = nil)
|
9
|
+
raise ArgumentError unless searcher.nil? || searcher.is_a?(Vpsa::Searcher::Financial::DefaultEntrySearcher)
|
10
|
+
|
11
|
+
return parse_response(self.class.get("/", :body => build_body(searcher.as_parameter), :headers => header)) if searcher
|
12
|
+
return parse_response(self.class.get("/", :body => build_body, :headers => header)) unless searcher
|
13
|
+
end
|
14
|
+
|
15
|
+
def find(id)
|
16
|
+
return parse_response(self.class.get("/#{id}", :body => build_body, :headers => header))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Vpsa
|
2
|
+
module Api
|
3
|
+
class Entities < Client
|
4
|
+
require_all 'vpsa/searcher/administrative', 'entity_searcher'
|
5
|
+
|
6
|
+
base_uri "https://www.vpsa.com.br/apps/api/entidades"
|
7
|
+
|
8
|
+
def list(searcher = nil)
|
9
|
+
raise ArgumentError unless searcher.nil? || searcher.is_a?(Vpsa::Searcher::Administrative::EntitySearcher)
|
10
|
+
|
11
|
+
return parse_response(self.class.get("/", :body => build_body(searcher.as_parameter), :headers => header)) if searcher
|
12
|
+
return parse_response(self.class.get("/", :body => build_body, :headers => header)) unless searcher
|
13
|
+
end
|
14
|
+
|
15
|
+
def find(id)
|
16
|
+
return parse_response(self.class.get("/#{id}", :body => build_body, :headers => header))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Vpsa
|
2
|
+
module Api
|
3
|
+
class ThirdParties < Client
|
4
|
+
require_all 'vpsa/searcher/administrative', 'third_party_searcher'
|
5
|
+
|
6
|
+
base_uri "https://www.vpsa.com.br/apps/api/terceiros"
|
7
|
+
|
8
|
+
def list(searcher = nil)
|
9
|
+
raise ArgumentError unless searcher.nil? || searcher.is_a?(Vpsa::Searcher::Administrative::ThirdPartySearcher)
|
10
|
+
|
11
|
+
return parse_response(self.class.get("/", :body => build_body(searcher.as_parameter), :headers => header)) if searcher
|
12
|
+
return parse_response(self.class.get("/", :body => build_body, :headers => header)) unless searcher
|
13
|
+
end
|
14
|
+
|
15
|
+
def find(id)
|
16
|
+
return parse_response(self.class.get("/#{id}", :body => build_body, :headers => header))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/vpsa/client.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require "httparty"
|
2
|
+
|
3
|
+
module Vpsa
|
4
|
+
class Client
|
5
|
+
extend Vpsa::ClassMethods
|
6
|
+
include HTTParty
|
7
|
+
|
8
|
+
default_options.update(verify: false)
|
9
|
+
parser Proc.new {|b| JSON.parse(b) rescue b}
|
10
|
+
|
11
|
+
require_all 'vpsa/api', 'third_parties', 'entities', 'default_entries', 'provisions'
|
12
|
+
|
13
|
+
attr_accessor :access_token
|
14
|
+
|
15
|
+
def initialize(access_token)
|
16
|
+
raise NoAccessTokenError if access_token.nil? || access_token.strip == ""
|
17
|
+
@access_token = access_token
|
18
|
+
end
|
19
|
+
|
20
|
+
def third_parties
|
21
|
+
Vpsa::Api::ThirdParties.new(@access_token)
|
22
|
+
end
|
23
|
+
|
24
|
+
def entities
|
25
|
+
Vpsa::Api::Entities.new(@access_token)
|
26
|
+
end
|
27
|
+
|
28
|
+
def default_entries
|
29
|
+
Vpsa::Api::DefaultEntries.new(@access_token)
|
30
|
+
end
|
31
|
+
|
32
|
+
def provisions
|
33
|
+
Vpsa::Api::Provisions.new(@access_token)
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
def header
|
38
|
+
{"Content-Type" => "application/json", "Accept" => "application/json"}
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_body(parameters = {})
|
42
|
+
parameters.merge(:token => @access_token).to_json
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse_response(response)
|
46
|
+
return Vpsa::Client::Response.new(response)
|
47
|
+
end
|
48
|
+
|
49
|
+
class Response
|
50
|
+
attr_accessor :status, :payload, :raw_response
|
51
|
+
|
52
|
+
def initialize(response)
|
53
|
+
@status = response.code
|
54
|
+
@payload = response.parsed_response
|
55
|
+
@raw_response = response
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class NoAccessTokenError < StandardError
|
60
|
+
def message
|
61
|
+
"Please provide an access token"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'vpsa/init_from_hash'
|
2
|
+
|
3
|
+
module Vpsa
|
4
|
+
module Entity
|
5
|
+
class Base
|
6
|
+
include Vpsa::InitFromHash
|
7
|
+
|
8
|
+
def as_parameter
|
9
|
+
variables = instance_variables.map do |name|
|
10
|
+
variable_name = name.to_s.tr("@", "")
|
11
|
+
|
12
|
+
[variable_name, instance_variable_get(name)]
|
13
|
+
end
|
14
|
+
|
15
|
+
Hash[variables]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'vpsa/init_from_hash'
|
2
|
+
|
3
|
+
module Vpsa
|
4
|
+
module Searcher
|
5
|
+
class Base
|
6
|
+
include InitFromHash
|
7
|
+
|
8
|
+
attr_accessor :inicio, :quantidade
|
9
|
+
|
10
|
+
def as_parameter
|
11
|
+
variables = instance_variables.map do |name|
|
12
|
+
variable_name = name.to_s.tr("@", "")
|
13
|
+
|
14
|
+
[variable_name, instance_variable_get(name)]
|
15
|
+
end
|
16
|
+
|
17
|
+
Hash[variables]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/vpsa/version.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Vpsa::Api::DefaultEntries do
|
4
|
+
let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
|
5
|
+
|
6
|
+
describe "listing" do
|
7
|
+
before(:each) do
|
8
|
+
stub_request(:get, "https://www.vpsa.com.br/apps/api/lancamentos-padroes/").to_return(:status => 200)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should issue a get to the default_entries url" do
|
12
|
+
expect(Vpsa::Api::DefaultEntries).to receive(:get).with("/", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
13
|
+
|
14
|
+
Vpsa.new("abc").default_entries.list()
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should issue a get to the default_entries url using the searcher" do
|
18
|
+
searcher = Vpsa::Searcher::Financial::DefaultEntrySearcher.new({:quantidade => 10, :inicio => 0})
|
19
|
+
|
20
|
+
expect(Vpsa::Api::DefaultEntries).to receive(:get).with("/", :body => searcher.as_parameter.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
|
21
|
+
|
22
|
+
Vpsa.new("abc").default_entries.list(searcher)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise ArgumentError if the parameter is not a DefaultEntrySearcher" do
|
26
|
+
expect{Vpsa.new("abc").default_entries.list(Array.new)}.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "finding" do
|
31
|
+
before(:each) do
|
32
|
+
stub_request(:get, "https://www.vpsa.com.br/apps/api/lancamentos-padroes/5").to_return(:status => 200)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should issue a get to the default entry url" do
|
36
|
+
expect(Vpsa::Api::DefaultEntries).to receive(:get).with("/5", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
37
|
+
|
38
|
+
Vpsa.new("abc").default_entries.find(5)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Vpsa::Api::Entities do
|
4
|
+
let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
|
5
|
+
|
6
|
+
describe "listing" do
|
7
|
+
before(:each) do
|
8
|
+
stub_request(:get, "https://www.vpsa.com.br/apps/api/entidades/").to_return(:status => 200)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should issue a get to the entities url" do
|
12
|
+
expect(Vpsa::Api::Entities).to receive(:get).with("/", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
13
|
+
|
14
|
+
Vpsa.new("abc").entities.list()
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should issue a get to the entities url using the searcher" do
|
18
|
+
searcher = Vpsa::Searcher::Administrative::EntitySearcher.new({:quantidade => 10, :inicio => 0})
|
19
|
+
|
20
|
+
expect(Vpsa::Api::Entities).to receive(:get).with("/", :body => searcher.as_parameter.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
|
21
|
+
|
22
|
+
Vpsa.new("abc").entities.list(searcher)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise ArgumentError if the parameter is not a EntitySearcher" do
|
26
|
+
expect{Vpsa.new("abc").entities.list(Array.new)}.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "finding" do
|
31
|
+
before(:each) do
|
32
|
+
stub_request(:get, "https://www.vpsa.com.br/apps/api/entidades/5").to_return(:status => 200)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should issue a get to the entity url" do
|
36
|
+
expect(Vpsa::Api::Entities).to receive(:get).with("/5", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
37
|
+
|
38
|
+
Vpsa.new("abc").entities.find(5)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Vpsa::Api::Provisions do
|
4
|
+
let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
|
5
|
+
|
6
|
+
describe "listing" do
|
7
|
+
before(:each) do
|
8
|
+
stub_request(:post, "https://www.vpsa.com.br/apps/api/provisoes/").to_return(:status => 201)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:provision_param) {{:"idLancamentoPadrao" => 3, :"idEntidade" => 1, :"idTerceiro" => 2, :data => "25-02-2019", :valor => "123.50", :historico => "histórico"}}
|
12
|
+
|
13
|
+
it "should issue a post to the provisions url" do
|
14
|
+
expect(Vpsa::Api::Provisions).to receive(:post).with("/", :body => provision_param.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
|
15
|
+
|
16
|
+
Vpsa.new("abc").provisions.create(provision_param)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Vpsa::Api::ThirdParties do
|
4
|
+
let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
|
5
|
+
|
6
|
+
describe "listing" do
|
7
|
+
before(:each) do
|
8
|
+
stub_request(:get, "https://www.vpsa.com.br/apps/api/terceiros/").to_return(:status => 200)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should issue a get to the third_parties url" do
|
12
|
+
expect(Vpsa::Api::ThirdParties).to receive(:get).with("/", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
13
|
+
|
14
|
+
Vpsa.new("abc").third_parties.list()
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should issue a get to the third_parties url using the searcher" do
|
18
|
+
searcher = Vpsa::Searcher::Administrative::ThirdPartySearcher.new({:quantidade => 10, :inicio => 0})
|
19
|
+
|
20
|
+
expect(Vpsa::Api::ThirdParties).to receive(:get).with("/", :body => searcher.as_parameter.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
|
21
|
+
|
22
|
+
Vpsa.new("abc").third_parties.list(searcher)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise ArgumentError if the parameter is not a ThirdPartySearcher" do
|
26
|
+
expect{Vpsa.new("abc").third_parties.list(Array.new)}.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "finding" do
|
31
|
+
before(:each) do
|
32
|
+
stub_request(:get, "https://www.vpsa.com.br/apps/api/terceiros/5").to_return(:status => 200)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should issue a get to the third party url" do
|
36
|
+
expect(Vpsa::Api::ThirdParties).to receive(:get).with("/5", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
37
|
+
|
38
|
+
Vpsa.new("abc").third_parties.find(5)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Vpsa::Client do
|
4
|
+
it "should return a new Vpsa::Api::ThirdParties" do
|
5
|
+
expect(Vpsa.new("abc").third_parties.class).to eq(Vpsa::Api::ThirdParties)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return a new Vpsa::Api::Entities" do
|
9
|
+
expect(Vpsa.new("abc").entities.class).to eq(Vpsa::Api::Entities)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return a new Vpsa::Api::DefaultEntries" do
|
13
|
+
expect(Vpsa.new("abc").default_entries.class).to eq(Vpsa::Api::DefaultEntries)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return a new Vpsa::Api::Provisions" do
|
17
|
+
expect(Vpsa.new("abc").provisions.class).to eq(Vpsa::Api::Provisions)
|
18
|
+
end
|
19
|
+
end
|
data/spec/vpsa_spec.rb
ADDED
data/vpsa.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vpsa/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vpsa"
|
8
|
+
spec.version = Vpsa::VERSION
|
9
|
+
spec.authors = ["Gustavo Berdugo"]
|
10
|
+
spec.email = ["gberdugo@gmail.com"]
|
11
|
+
spec.summary = %q{This gem provides integration with VPSA APIs (http://www.vpsa.com.br/)}
|
12
|
+
spec.description = %q{The goal of this gem is to simplify the access to VPSA API (http://www.vpsa.com.br/), for more information about this API, visit: https://github.com/VPSA/api/wiki/}
|
13
|
+
spec.homepage = "https://github.com/coyosoftware/vpsa"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency('httparty', "~> 0.13")
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vpsa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gustavo Berdugo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
description: 'The goal of this gem is to simplify the access to VPSA API (http://www.vpsa.com.br/),
|
42
|
+
for more information about this API, visit: https://github.com/VPSA/api/wiki/'
|
43
|
+
email:
|
44
|
+
- gberdugo@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".travis.yml"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- lib/vpsa.rb
|
56
|
+
- lib/vpsa/api/default_entries.rb
|
57
|
+
- lib/vpsa/api/entities.rb
|
58
|
+
- lib/vpsa/api/provisions.rb
|
59
|
+
- lib/vpsa/api/third_parties.rb
|
60
|
+
- lib/vpsa/client.rb
|
61
|
+
- lib/vpsa/entity/base.rb
|
62
|
+
- lib/vpsa/init_from_hash.rb
|
63
|
+
- lib/vpsa/searcher/administrative/entity_searcher.rb
|
64
|
+
- lib/vpsa/searcher/administrative/third_party_searcher.rb
|
65
|
+
- lib/vpsa/searcher/base.rb
|
66
|
+
- lib/vpsa/searcher/financial/default_entry_searcher.rb
|
67
|
+
- lib/vpsa/version.rb
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
- spec/vpsa/api/default_entries_spec.rb
|
70
|
+
- spec/vpsa/api/entities_spec.rb
|
71
|
+
- spec/vpsa/api/provisions_spec.rb
|
72
|
+
- spec/vpsa/api/third_parties_spec.rb
|
73
|
+
- spec/vpsa/client_spec.rb
|
74
|
+
- spec/vpsa_spec.rb
|
75
|
+
- vpsa.gemspec
|
76
|
+
homepage: https://github.com/coyosoftware/vpsa
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.4.5
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: This gem provides integration with VPSA APIs (http://www.vpsa.com.br/)
|
100
|
+
test_files:
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
- spec/vpsa/api/default_entries_spec.rb
|
103
|
+
- spec/vpsa/api/entities_spec.rb
|
104
|
+
- spec/vpsa/api/provisions_spec.rb
|
105
|
+
- spec/vpsa/api/third_parties_spec.rb
|
106
|
+
- spec/vpsa/client_spec.rb
|
107
|
+
- spec/vpsa_spec.rb
|
108
|
+
has_rdoc:
|