promoqui-api-sdk 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pqsdk.rb +1 -0
- data/lib/pqsdk/offer.rb +14 -0
- data/lib/pqsdk/offer_batch.rb +33 -0
- data/lib/pqsdk/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69a288eb474ffffa2f3c090c531566460a2b8bbe
|
4
|
+
data.tar.gz: 915bf9865b14c0e36966af793926936a382f002d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4db35dd9c229b2e0abcb8e5164dabd539192f03f3587f5a942fbe4d14a4de72ae00195ce35c0a77357461edfa7015ea29efc0be75ff0936d393bd7fd2d40e4e
|
7
|
+
data.tar.gz: f8ad4430a0c094d719bfc348cf8ed5bfe733856abc99c016b28e2fee9566cbb4402139441c0ea8088bfe62ce848490843762cdb657710dad4253176330f163f2
|
data/lib/pqsdk.rb
CHANGED
data/lib/pqsdk/offer.rb
CHANGED
@@ -30,5 +30,19 @@ module PQSDK
|
|
30
30
|
raise Exception.new("Unexpected HTTP status code #{res[0]}")
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
def to_hash
|
35
|
+
{
|
36
|
+
title: title,
|
37
|
+
description: description,
|
38
|
+
price: price,
|
39
|
+
original_price: original_price,
|
40
|
+
discount: discount,
|
41
|
+
start_date: start_date,
|
42
|
+
end_date: end_date,
|
43
|
+
image: image,
|
44
|
+
store_ids: store_ids
|
45
|
+
}
|
46
|
+
end
|
33
47
|
end
|
34
48
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module PQSDK
|
2
|
+
class OfferBatch
|
3
|
+
attr_accessor :offers
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@offers = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def <<(offer)
|
10
|
+
@offers << offer
|
11
|
+
end
|
12
|
+
|
13
|
+
def save
|
14
|
+
request = []
|
15
|
+
method = :post
|
16
|
+
endpoint = "v1/offers"
|
17
|
+
|
18
|
+
@offers.each do |offer|
|
19
|
+
request << offer.to_hash
|
20
|
+
end
|
21
|
+
|
22
|
+
res = RestLayer.send(method, endpoint, request, {'Authorization' => "Bearer #{Token.access_token}", 'Content-Type' => 'application/json'})
|
23
|
+
|
24
|
+
if res[0] == 200
|
25
|
+
# All right!
|
26
|
+
elsif res[0] == 400
|
27
|
+
raise Exception.new("Bad request! Error: #{res[1]['errors']}")
|
28
|
+
else
|
29
|
+
raise Exception.new("Unexpected HTTP status code #{res[0]}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/pqsdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promoqui-api-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Boffa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/pqsdk/city.rb
|
35
35
|
- lib/pqsdk/leaflet.rb
|
36
36
|
- lib/pqsdk/offer.rb
|
37
|
+
- lib/pqsdk/offer_batch.rb
|
37
38
|
- lib/pqsdk/rest_layer.rb
|
38
39
|
- lib/pqsdk/settings.rb
|
39
40
|
- lib/pqsdk/store.rb
|