promoqui-api-sdk 1.7.5 → 1.7.6

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: 80fc62469f5887af483f911d6e6309d78e647b4f
4
- data.tar.gz: cac0ea0fbafd27b556d7dd91fda9c7c8feb179b6
3
+ metadata.gz: 2b13f61e2c551f0f39f78f8e64bbd6f03cf16236
4
+ data.tar.gz: 9ca7240914297bada270bb7ea326af57947554b6
5
5
  SHA512:
6
- metadata.gz: 7ee01b9cd8674f7262176d5186943f7b5c8e254f1866ce23b0409198a0e5f90b35b5e29dc9e3e13e0ac7cba8c178e3cc1c61a4c1580f3a7a1b9fb3d524c93267
7
- data.tar.gz: 836ec342f678ae8b729083e85caa83eb31377b971b7a23d4646500f4ecb86de49302bdae3aa6d86fc7283e5e6f85ea2a5e734329a5eb36153c35f951e28751e9
6
+ metadata.gz: 5b50b678fd528e1302b093c6f1acde6814ef7ce055eda5f94b3b7469ac6c21061a145f5f1d211991da390ccc5888786eda8b21b6b1e63dde730254c65ebac4c4
7
+ data.tar.gz: 8d5cda8cc7a317316d8b2de1e1f91c0f08290a78d31c8c81341ed564a47af63f0d2ce1cac61b07c2126798bceb37039321a18d9b6ce41159c03a757d519e9b8f
@@ -47,7 +47,12 @@ module PQSDK
47
47
  def self.put(endpoint, parameters, headers)
48
48
  url = URI.parse("#{Settings.schema}://#{Settings.host}/#{endpoint}")
49
49
  req = Net::HTTP::Put.new(url.request_uri)
50
- req.set_form_data(parameters)
50
+
51
+ if headers['Content-Type'] == 'application/json'
52
+ req.body = parameters.to_json
53
+ else
54
+ req.set_form_data(parameters)
55
+ end
51
56
 
52
57
  headers.each do |name, value|
53
58
  req[name.to_s] = value
@@ -64,7 +69,7 @@ module PQSDK
64
69
  private
65
70
  def self.check_status(code, body)
66
71
  if code >= 500
67
- raise Exception.new("Internal Server Error")
72
+ raise Exception.new("Internal Server Error: " + body)
68
73
  elsif code == 401
69
74
  raise Exception.new("You are not authorized to perform that request")
70
75
  end
data/lib/pqsdk/store.rb CHANGED
@@ -44,26 +44,26 @@ module PQSDK
44
44
  expected_status = 201
45
45
  end
46
46
 
47
- fields = {}
48
- [ :name, :address, :zipcode, :latitude, :longitude, :origin ].each do |field|
49
- raise "Missing required #{field} field" if send(field).to_s == ''
50
- fields[field.to_s] = send(field)
51
- end
52
-
53
47
  if city.nil? and city_id.nil?
54
48
  raise "city or city_id must be set"
55
49
  end
56
50
 
57
- fields['city'] = city if city
58
- fields['city_id'] = city_id if city_id
51
+ fields = {}
52
+ if method != :put
53
+ [ :name, :address, :zipcode, :latitude, :longitude, :origin ].each do |field|
54
+ raise "Missing required #{field} field" if send(field).to_s == ''
55
+ fields[field.to_s] = send(field)
56
+ end
59
57
 
60
- fields['leaflet_ids'] = leaflet_ids.try(:to_json) || []
58
+ fields['city'] = city if city
59
+ fields['city_id'] = city_id if city_id
60
+ fields['phone'] = phone if phone
61
+ end
61
62
 
62
- fields['phone'] = phone unless phone.nil?
63
- fields['opening_hours'] = opening_hours.to_json unless opening_hours.to_a.empty?
64
- fields['opening_hours_text'] = opening_hours_text unless opening_hours_text.nil?
63
+ fields['opening_hours'] = opening_hours if opening_hours.try(:any?)
64
+ fields['opening_hours_text'] = opening_hours_text if opening_hours_text.present?
65
65
 
66
- res = RestLayer.send(method, url, fields, { 'Authorization' => "Bearer #{Token.access_token}" })
66
+ res = RestLayer.send(method, url, fields, { 'Authorization' => "Bearer #{Token.access_token}", 'Content-Type' => 'application/json' })
67
67
 
68
68
  if res[0] != expected_status
69
69
  raise Exception.new("Unexpected HTTP status code #{res[0]}")
data/lib/pqsdk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PQSDK
2
- VERSION = '1.7.5'
2
+ VERSION = '1.7.6'
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.5
4
+ version: 1.7.6
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-01 00:00:00.000000000 Z
11
+ date: 2015-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json