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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c03adf54de6fcfb81dc54ac6eecb79b2d4e73d4f
4
- data.tar.gz: 1c2250cc688aef0fd45c201eda56891426085269
3
+ metadata.gz: 69a288eb474ffffa2f3c090c531566460a2b8bbe
4
+ data.tar.gz: 915bf9865b14c0e36966af793926936a382f002d
5
5
  SHA512:
6
- metadata.gz: ad3b3c557e936bf71ddef901f9c41b05c0ea940b6d240d845c8f2fa7daf0d84e00bdc61a5f13b137d0c117a03267cb7f2da473e31ec302162472b0e189dd0bfc
7
- data.tar.gz: 7e1352b9ea9e73021b18b2e00fd95c76290d5b249ab528d4b1958a37ca338f76b892a33eb081fae8788dbdd434d6a1282da80be8ba8de9e89ae74f80bcb3d301
6
+ metadata.gz: d4db35dd9c229b2e0abcb8e5164dabd539192f03f3587f5a942fbe4d14a4de72ae00195ce35c0a77357461edfa7015ea29efc0be75ff0936d393bd7fd2d40e4e
7
+ data.tar.gz: f8ad4430a0c094d719bfc348cf8ed5bfe733856abc99c016b28e2fee9566cbb4402139441c0ea8088bfe62ce848490843762cdb657710dad4253176330f163f2
data/lib/pqsdk.rb CHANGED
@@ -4,6 +4,7 @@ require 'time'
4
4
  require 'pqsdk/city'
5
5
  require 'pqsdk/leaflet'
6
6
  require 'pqsdk/offer'
7
+ require 'pqsdk/offer_batch'
7
8
  require 'pqsdk/rest_layer'
8
9
  require 'pqsdk/settings'
9
10
  require 'pqsdk/store'
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
@@ -1,3 +1,3 @@
1
1
  module PQSDK
2
- VERSION = '1.6.0'
2
+ VERSION = '1.7.0'
3
3
  end
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.6.0
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-09 00:00:00.000000000 Z
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