sunlight_api 1.2.0 → 1.2.1

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: 5d9b50c00487de294313d8b3b159cdafbbf49491
4
- data.tar.gz: f85d378b8b70838d8d3fd7d81e6dbc3eb6057c38
3
+ metadata.gz: f80a63f85c0b69dc99b029ab67cf3d6d2ea69424
4
+ data.tar.gz: dbbae03e3fd7f300e595badba20818618d567cba
5
5
  SHA512:
6
- metadata.gz: 46733f550b93e1b85f64d79fea74ac3f68a9dbdce0ee49ecc4ba02c1acfb44afe77cf70a0b75a9504599b2e13a7824b92e9b311a5da20dbb0ed9c641309b172b
7
- data.tar.gz: 128b6e70b68f9baef96dbab4c245b50b0d46fff07f44bae0aed0565919e6541b09a7f44a42f9aa3107629ca9be0565973714b04a4ee610486650131318c0121d
6
+ metadata.gz: 2df5e4655b3d159b8698f5bfb42ab92610b0089a3d957eb675004c6138d8ba91808326dcae4a7f11690369840c0ff1cf74a216533eaa143485d7ed1144d80088
7
+ data.tar.gz: 23d1f346c4e107bdb33645563a844384aebfec74079962f6e23b2eb42bc1adc4abda29a687835f8f7b8baa5e8a86c3c08e32ae870c5e912053bad10ac7820434
@@ -6,19 +6,32 @@ require "resolv-replace.rb"
6
6
 
7
7
  module SunlightApi
8
8
  class Client
9
- def initialize( public_key, private_key )
9
+ def initialize( public_key, private_key, test=false )
10
10
  @public_key = public_key
11
11
  @private_key = private_key
12
+ @test = test
12
13
  end
13
14
 
14
15
  def request( action )
15
- uri = SunlightApi::UriGenerator::new(@public_key, @private_key, action, {format: "json"}).url
16
+ uri = SunlightApi::UriGenerator::new(@public_key, @private_key, @test, action, {format: "json"}).url
16
17
  rclient = Rquest::new({verb: :get, uri: uri})
17
18
  body = rclient.send
18
19
  return nil if body.class == Hash and not body['error'].nil?
19
20
  JSON::parse( body )
20
21
  end
21
22
 
23
+ def post_request( action, params )
24
+ uri = SunlightApi::UriGenerator::new(@public_key, @private_key, @test, action, {format: "json"}).url
25
+ rclient = Rquest::new({verb: :post, uri: uri, payload: params})
26
+ body = rclient.send
27
+ return nil if body.class == Hash and not body['error'].nil?
28
+ JSON::parse( body )
29
+ end
30
+
31
+ def place_order(params )
32
+ post_request("order", params)
33
+ end
34
+
22
35
  def inventory
23
36
  request("inventory")
24
37
  end
@@ -57,10 +70,15 @@ module SunlightApi
57
70
  end
58
71
  class UriGenerator
59
72
  attr_reader :url
60
- def initialize( public_key, private_key, uri_suffix, get_params={} )
73
+ def initialize( public_key, private_key, test, uri_suffix, get_params={} )
61
74
  @public_key = public_key
62
75
  @private_key = private_key
63
- @base_url = "https://services.sunlightsupply.com/v1/#{uri_suffix}?"
76
+ @test = test
77
+ if @test
78
+ @base_url = "https://hortservices.sunlightsupply.com/v1/#{uri_suffix}?"
79
+ else
80
+ @base_url = "https://services.sunlightsupply.com/v1/#{uri_suffix}?"
81
+ end
64
82
  @get_params = get_params
65
83
  @time_stamp = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
66
84
  append_get_params
@@ -1,3 +1,3 @@
1
1
  module SunlightApi
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunlight_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Tyrel Corporation
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-28 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,9 +114,11 @@ files:
114
114
  - bin/console
115
115
  - bin/setup
116
116
  - lib/sunlight_api.rb
117
+ - lib/sunlight_api/.version.rb.swp
117
118
  - lib/sunlight_api/version.rb
118
119
  - sunlight_api-1.0.0.gem
119
120
  - sunlight_api-1.1.0.gem
121
+ - sunlight_api-1.2.0.gem
120
122
  - sunlight_api.gemspec
121
123
  homepage: https://github.com/thetyrelcorporation/sunlight_api
122
124
  licenses:
@@ -138,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
140
  version: '0'
139
141
  requirements: []
140
142
  rubyforge_project:
141
- rubygems_version: 2.2.3
143
+ rubygems_version: 2.4.8
142
144
  signing_key:
143
145
  specification_version: 4
144
146
  summary: Access specifications and stock levels for sunlight supplies product line