vpsa 0.0.28 → 0.0.29
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/lib/vpsa/api/orders.rb +7 -0
- data/lib/vpsa/api/products.rb +2 -2
- data/lib/vpsa/entity/commercial/item.rb +13 -0
- data/lib/vpsa/entity/commercial/order.rb +14 -0
- data/lib/vpsa/version.rb +1 -1
- data/spec/vpsa/api/orders_spec.rb +15 -0
- data/spec/vpsa/api/products_spec.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f117d0616b4ec9ff6c336ebe75df8082730865d
|
4
|
+
data.tar.gz: 29c888dcf13ee26282ae7649e2ee1815a85a66ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 985afb853597e478f45f7b2b7d1d46d9cc9e9605fd3e578104eecfb0fbdd188343a4207d7dff68359e0ac878e0e973a77e1847f45f346228a5f016ef3be1ff54
|
7
|
+
data.tar.gz: 1411e7172b76e4e722c6b6463ee0477da610040977889bf0067d0d1ad9dbda7f33ef0f540de944dcbc3ce4bd2d6af03107ccc9671bcc8e13e5083ebf61ce869c
|
data/lib/vpsa/api/orders.rb
CHANGED
@@ -2,6 +2,7 @@ module Vpsa
|
|
2
2
|
module Api
|
3
3
|
class Orders < Client
|
4
4
|
require_all 'vpsa/searcher/operational', 'order_searcher'
|
5
|
+
require_all 'vpsa/entity/commercial', 'order', 'item'
|
5
6
|
|
6
7
|
base_uri "#{Vpsa::API_ADDRESS}/pedidos"
|
7
8
|
|
@@ -15,6 +16,12 @@ module Vpsa
|
|
15
16
|
def find(id)
|
16
17
|
return parse_response(self.class.get("/#{id}", :body => build_body, :headers => header))
|
17
18
|
end
|
19
|
+
|
20
|
+
def save(order)
|
21
|
+
raise ArgumentError unless order.nil? || order.is_a?(Vpsa::Entity::Commercial::Order)
|
22
|
+
return parse_response(self.class.post("/", :body => build_body(order.as_parameter), :headers => header))
|
23
|
+
end
|
24
|
+
|
18
25
|
end
|
19
26
|
end
|
20
27
|
end
|
data/lib/vpsa/api/products.rb
CHANGED
@@ -6,11 +6,11 @@ module Vpsa
|
|
6
6
|
base_uri "#{Vpsa::API_ADDRESS}/produtos"
|
7
7
|
|
8
8
|
def save(data)
|
9
|
-
return parse_response(self.class.post("/", :body => build_body(data), :headers => header))
|
9
|
+
return parse_response(self.class.post("/", :body => build_body(data.as_parameter), :headers => header))
|
10
10
|
end
|
11
11
|
|
12
12
|
def update(id, data)
|
13
|
-
return parse_response(self.class.put("/#{id}", :body => build_body(data), :headers => header))
|
13
|
+
return parse_response(self.class.put("/#{id}", :body => build_body(data.as_parameter), :headers => header))
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'vpsa/entity/base'
|
2
|
+
|
3
|
+
module Vpsa
|
4
|
+
module Entity
|
5
|
+
module Commercial
|
6
|
+
class Order < Base
|
7
|
+
|
8
|
+
attr_accessor :data, :horario, :idEntidade, :idPlanoPagamento, :idRepresentante, :idTerceiro,
|
9
|
+
:observacao, :valorFrete, :valorOutros, :valorSeguro, :vendaConsumidorFinal, :itens
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/vpsa/version.rb
CHANGED
@@ -2,6 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Vpsa::Api::Orders do
|
4
4
|
let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
|
5
|
+
let(:order_param) {{}}
|
5
6
|
|
6
7
|
describe "listing" do
|
7
8
|
before(:each) do
|
@@ -38,4 +39,18 @@ RSpec.describe Vpsa::Api::Orders do
|
|
38
39
|
Vpsa.new("abc").orders.find(5)
|
39
40
|
end
|
40
41
|
end
|
42
|
+
|
43
|
+
describe "save" do
|
44
|
+
before(:each) do
|
45
|
+
stub_request(:post, "#{Vpsa::API_ADDRESS}/pedidos/").to_return(:status => 201)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should issue a post to the orders url" do
|
49
|
+
order = Vpsa::Entity::Commercial::Order.new
|
50
|
+
|
51
|
+
expect(Vpsa::Api::Orders).to receive(:post).with("/", :body => order.as_parameter.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
|
52
|
+
Vpsa.new("abc").orders.save(order)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
41
56
|
end
|
@@ -13,7 +13,7 @@ RSpec.describe Vpsa::Api::Products do
|
|
13
13
|
it "should issue a post to the products url" do
|
14
14
|
expect(Vpsa::Api::Products).to receive(:post).with("/", :body => product_param.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
|
15
15
|
|
16
|
-
Vpsa.new("abc").products.save(
|
16
|
+
Vpsa.new("abc").products.save(Vpsa::Entity::Commercial::Product.new)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -25,7 +25,7 @@ RSpec.describe Vpsa::Api::Products do
|
|
25
25
|
it "should issue a put to the installments url" do
|
26
26
|
expect(Vpsa::Api::Products).to receive(:put).with("/1", :body => product_param.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
|
27
27
|
|
28
|
-
Vpsa.new("abc").products.update(1,
|
28
|
+
Vpsa.new("abc").products.update(1, Vpsa::Entity::Commercial::Product.new)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vpsa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.29
|
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-10-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -77,6 +77,8 @@ files:
|
|
77
77
|
- lib/vpsa/entity/base.rb
|
78
78
|
- lib/vpsa/entity/commercial/credit_limit.rb
|
79
79
|
- lib/vpsa/entity/commercial/installment.rb
|
80
|
+
- lib/vpsa/entity/commercial/item.rb
|
81
|
+
- lib/vpsa/entity/commercial/order.rb
|
80
82
|
- lib/vpsa/entity/commercial/product.rb
|
81
83
|
- lib/vpsa/entity/operational/category_level.rb
|
82
84
|
- lib/vpsa/entity/operational/product_category.rb
|