promoqui-api-sdk 1.7.6 → 1.7.7

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: 2b13f61e2c551f0f39f78f8e64bbd6f03cf16236
4
- data.tar.gz: 9ca7240914297bada270bb7ea326af57947554b6
3
+ metadata.gz: ce270a95c42e5445ff87e9d0efe52218ccf1df8c
4
+ data.tar.gz: d3842f9ceb30f554cda9438f52c36c1c86162125
5
5
  SHA512:
6
- metadata.gz: 5b50b678fd528e1302b093c6f1acde6814ef7ce055eda5f94b3b7469ac6c21061a145f5f1d211991da390ccc5888786eda8b21b6b1e63dde730254c65ebac4c4
7
- data.tar.gz: 8d5cda8cc7a317316d8b2de1e1f91c0f08290a78d31c8c81341ed564a47af63f0d2ce1cac61b07c2126798bceb37039321a18d9b6ce41159c03a757d519e9b8f
6
+ metadata.gz: 07201749320f0add199368b6416945d60e7b9b1ccbf9c72664f32151f64e8f0b6d54a3b5bf330e6872f40202bc5c0d5caaf430cd3741aec24c255fe8fb8dbb9e
7
+ data.tar.gz: ede1ba8d8b89f63284451e740a2c228f8d19489a07267478e68a6bed4376c289a2b7c1056a586d86439e7dfd5850009ef11a09ed68d132721f7ee931568034ee
@@ -1,6 +1,7 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
3
  require 'time'
4
+ require 'pqsdk/brand'
4
5
  require 'pqsdk/city'
5
6
  require 'pqsdk/leaflet'
6
7
  require 'pqsdk/offer'
@@ -0,0 +1,38 @@
1
+ module PQSDK
2
+ class Brand
3
+ attr_accessor :id, :name, :slug
4
+
5
+ def self.list
6
+ res = RestLayer.get('v1/brands', {}, { 'Authorization' => "Bearer #{Token.access_token}" })
7
+ if res[0] == 200
8
+ res[1].map{|brand| Brand.from_json(brand)}
9
+ elsif res[0] == 404
10
+ nil
11
+ else
12
+ raise Exception.new("Unexpected HTTP status code #{res[0]}")
13
+ end
14
+ end
15
+
16
+ def self.find(name)
17
+ res = RestLayer.get('v1/brands/search', { q: name }, { 'Authorization' => "Bearer #{Token.access_token}" })
18
+ if res[0] == 200
19
+ Brand.from_json res[1]
20
+ elsif res[0] == 404
21
+ nil
22
+ else
23
+ raise Exception.new("Unexpected HTTP status code #{res[0]}")
24
+ end
25
+ end
26
+
27
+ private
28
+ def self.from_json(json)
29
+ result = Brand.new
30
+
31
+ json.each do |key, val|
32
+ result.send("#{key}=", val)
33
+ end
34
+
35
+ result
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module PQSDK
2
- VERSION = '1.7.6'
2
+ VERSION = '1.7.7'
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.7.6
4
+ version: 1.7.7
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-12-04 00:00:00.000000000 Z
11
+ date: 2015-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -31,6 +31,7 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - lib/pqsdk.rb
34
+ - lib/pqsdk/brand.rb
34
35
  - lib/pqsdk/city.rb
35
36
  - lib/pqsdk/leaflet.rb
36
37
  - lib/pqsdk/offer.rb
@@ -60,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
61
  version: '0'
61
62
  requirements: []
62
63
  rubyforge_project:
63
- rubygems_version: 2.4.5
64
+ rubygems_version: 2.4.3
64
65
  signing_key:
65
66
  specification_version: 4
66
67
  summary: A wrapper around PromoQui HTTP Crawler API