vpsa 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 023176512b7357012488f1394ed135925b7374cf
4
- data.tar.gz: cd8720b6e766d132d2f9636782189cf985d50b84
3
+ metadata.gz: d42eeb55ced6f3b44bd295c4786d44e6176bfaee
4
+ data.tar.gz: 8b10170e20589348d809ac80a87e4ff1c4c4c8be
5
5
  SHA512:
6
- metadata.gz: 2db4b57b61398ca98097de654734b0f612668802025c0c99100ace3ff60d8baea77901afcd3f7fe695cada1ec03d5b007eba27fd672bafbd7e1376148adcc805
7
- data.tar.gz: b3146b36d3fce8bfa3a8f6280995efb598c0775341bdd2ce2c64976e56e6f6282267f7c53544c07e6ce8cf5529b135085e6db3ae0a89602b74da255f3f10d2d2
6
+ metadata.gz: e6fbd66525743aa3ab20e6d752d4481a9f654210c40dd54a51580ac220bf63f5e1a2c738d6122d51db7f78d0176f4ba86ca94cf943a669b7dd4a6f81e9659493
7
+ data.tar.gz: b92d12c5223776b7287dd2f075ffc1b44f51e837cd8ed5180624dd8bfeb968070fe531e0600d6423e36d14ebc456b149f0b8822e7075411a729c532167d59ec6
@@ -0,0 +1,28 @@
1
+ module Vpsa
2
+ module Api
3
+ class Installments < Client
4
+ require_all 'vpsa/searcher/financial', 'installment_searcher'
5
+
6
+ base_uri "https://www.vpsa.com.br/apps/api/crediarios"
7
+
8
+ def list(searcher = nil)
9
+ raise ArgumentError unless searcher.nil? || searcher.is_a?(Vpsa::Searcher::Financial::InstallmentSearcher)
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 create(data)
16
+ return parse_response(self.class.post("/", :body => build_body(data), :headers => header))
17
+ end
18
+
19
+ def update(id, data)
20
+ return parse_response(self.class.put("/#{id}", :body => build_body(data), :headers => header))
21
+ end
22
+
23
+ def find(id)
24
+ return parse_response(self.class.get("/#{id}", :body => build_body, :headers => header))
25
+ end
26
+ end
27
+ end
28
+ end
@@ -8,7 +8,7 @@ module Vpsa
8
8
  default_options.update(verify: false)
9
9
  parser Proc.new {|b| JSON.parse(b) rescue b}
10
10
 
11
- require_all 'vpsa/api', 'third_parties', 'entities', 'default_entries', 'provisions', 'user_data'
11
+ require_all 'vpsa/api', 'third_parties', 'entities', 'default_entries', 'provisions', 'user_data', 'installments'
12
12
 
13
13
  attr_accessor :access_token
14
14
 
@@ -37,6 +37,10 @@ module Vpsa
37
37
  Vpsa::Api::UserData.new(@access_token)
38
38
  end
39
39
 
40
+ def installments
41
+ Vpsa::Api::Installments.new(@access_token)
42
+ end
43
+
40
44
  protected
41
45
  def header
42
46
  {"Content-Type" => "application/json", "Accept" => "application/json"}
@@ -0,0 +1,10 @@
1
+ require 'vpsa/searcher/base'
2
+
3
+ module Vpsa
4
+ module Searcher
5
+ module Financial
6
+ class InstallmentSearcher < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Vpsa
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Vpsa::Api::Installments 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/crediarios/").to_return(:status => 200)
9
+ end
10
+
11
+ it "should issue a get to the installments url" do
12
+ expect(Vpsa::Api::Installments).to receive(:get).with("/", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
13
+
14
+ Vpsa.new("abc").installments.list
15
+ end
16
+
17
+ it "should raise ArgumentError if the parameter is not a InstallmentSearcher" do
18
+ expect{Vpsa.new("abc").installments.list(Array.new)}.to raise_error(ArgumentError)
19
+ end
20
+ end
21
+
22
+ describe "creation" do
23
+ before(:each) do
24
+ stub_request(:post, "https://www.vpsa.com.br/apps/api/crediarios/").to_return(:status => 201)
25
+ end
26
+
27
+ let(:installment_param) {{}}
28
+
29
+ it "should issue a post to the installments url" do
30
+ expect(Vpsa::Api::Installments).to receive(:post).with("/", :body => installment_param.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
31
+
32
+ Vpsa.new("abc").installments.create(installment_param)
33
+ end
34
+ end
35
+
36
+ describe "updating" do
37
+ before(:each) do
38
+ stub_request(:put, "https://www.vpsa.com.br/apps/api/crediarios/1").to_return(:status => 200)
39
+ end
40
+
41
+ let(:installment_param) {{}}
42
+
43
+ it "should issue a put to the installments url" do
44
+ expect(Vpsa::Api::Installments).to receive(:put).with("/1", :body => installment_param.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
45
+
46
+ Vpsa.new("abc").installments.update(1, installment_param)
47
+ end
48
+ end
49
+
50
+ describe "finding" do
51
+ before(:each) do
52
+ stub_request(:get, "https://www.vpsa.com.br/apps/api/crediarios/5").to_return(:status => 200)
53
+ end
54
+
55
+ it "should issue a get to the installment url" do
56
+ expect(Vpsa::Api::Installments).to receive(:get).with("/5", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
57
+
58
+ Vpsa.new("abc").installments.find(5)
59
+ end
60
+ end
61
+ end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  RSpec.describe Vpsa::Api::Provisions do
4
4
  let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
5
5
 
6
- describe "listing" do
6
+ describe "creation" do
7
7
  before(:each) do
8
8
  stub_request(:post, "https://www.vpsa.com.br/apps/api/provisoes-contas/").to_return(:status => 201)
9
9
  end
@@ -20,4 +20,8 @@ RSpec.describe Vpsa::Client do
20
20
  it "should return a new Vpsa::Api::UserData" do
21
21
  expect(Vpsa.new("abc").user_data.class).to eq(Vpsa::Api::UserData)
22
22
  end
23
+
24
+ it "should return a new Vpsa::Api::Installments" do
25
+ expect(Vpsa.new("abc").installments.class).to eq(Vpsa::Api::Installments)
26
+ end
23
27
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vpsa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Berdugo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-29 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.13'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.7'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.7'
41
41
  description: 'The goal of this gem is to simplify the access to VPSA API (http://www.vpsa.com.br/),
@@ -46,8 +46,8 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - ".gitignore"
50
- - ".travis.yml"
49
+ - .gitignore
50
+ - .travis.yml
51
51
  - Gemfile
52
52
  - LICENSE.txt
53
53
  - README.md
@@ -55,6 +55,7 @@ files:
55
55
  - lib/vpsa.rb
56
56
  - lib/vpsa/api/default_entries.rb
57
57
  - lib/vpsa/api/entities.rb
58
+ - lib/vpsa/api/installments.rb
58
59
  - lib/vpsa/api/provisions.rb
59
60
  - lib/vpsa/api/third_parties.rb
60
61
  - lib/vpsa/api/user_data.rb
@@ -65,10 +66,12 @@ files:
65
66
  - lib/vpsa/searcher/administrative/third_party_searcher.rb
66
67
  - lib/vpsa/searcher/base.rb
67
68
  - lib/vpsa/searcher/financial/default_entry_searcher.rb
69
+ - lib/vpsa/searcher/financial/installment_searcher.rb
68
70
  - lib/vpsa/version.rb
69
71
  - spec/spec_helper.rb
70
72
  - spec/vpsa/api/default_entries_spec.rb
71
73
  - spec/vpsa/api/entities_spec.rb
74
+ - spec/vpsa/api/installments_spec.rb
72
75
  - spec/vpsa/api/provisions_spec.rb
73
76
  - spec/vpsa/api/third_parties_spec.rb
74
77
  - spec/vpsa/api/user_data_spec.rb
@@ -85,12 +88,12 @@ require_paths:
85
88
  - lib
86
89
  required_ruby_version: !ruby/object:Gem::Requirement
87
90
  requirements:
88
- - - ">="
91
+ - - '>='
89
92
  - !ruby/object:Gem::Version
90
93
  version: '0'
91
94
  required_rubygems_version: !ruby/object:Gem::Requirement
92
95
  requirements:
93
- - - ">="
96
+ - - '>='
94
97
  - !ruby/object:Gem::Version
95
98
  version: '0'
96
99
  requirements: []
@@ -103,9 +106,9 @@ test_files:
103
106
  - spec/spec_helper.rb
104
107
  - spec/vpsa/api/default_entries_spec.rb
105
108
  - spec/vpsa/api/entities_spec.rb
109
+ - spec/vpsa/api/installments_spec.rb
106
110
  - spec/vpsa/api/provisions_spec.rb
107
111
  - spec/vpsa/api/third_parties_spec.rb
108
112
  - spec/vpsa/api/user_data_spec.rb
109
113
  - spec/vpsa/client_spec.rb
110
114
  - spec/vpsa_spec.rb
111
- has_rdoc: