pricesphere 0.1.0 → 0.2.0

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: 1ba34cbcc53ec5ef87bfacbe93bb0818c1f2d224
4
- data.tar.gz: 65e32973361db4a3dea4f610b69c1c427b01734e
3
+ metadata.gz: 70e7fd68fbeb72d98ce5b8c314047a45b05baf27
4
+ data.tar.gz: ac2807d98028a756462007005a7ca66b8d25c8e6
5
5
  SHA512:
6
- metadata.gz: fe289a93cf850074135513ede023ea3d7772c339b036f33bde30ad06c228b6ed08ca7df2c59b56c07d8edb088caf987c95950d92c4a3a970318786c01bc30f2a
7
- data.tar.gz: f12b6f2ed8283e6d7f650683e8d6ee2346b4153a856d9e0b4e81bcb0e1a44f72d1eb42e203ab47a4ab8b6d8f4068921ef5cf9c6538dec73fa77f9a862f5b205d
6
+ metadata.gz: 3a7c6985b0f3b0d2fed3160572b96ce18d7de43c56d21817db367376eb96303b747f2bf8dfb5411b9ad40dc385e630f334692b34983d0de152e0da47b25d29c2
7
+ data.tar.gz: 9105604527d5640f5fe991ff6d91c0bb8b9ac475048f5bbe48494a7ec6ce7b6cecf2a0186bb0601033fcc5b9e4db7dc62c5c7292492849f52070ef13218c3a5e
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pricesphere'
4
+
5
+ API_KEY = 'Your API Key'
6
+
7
+
8
+ pricesphere = Pricesphere::Watch.new(API_KEY)
9
+
10
+ pricesphere_product_id = 1
11
+ pricesphere.register(pricesphere_product_id, 'http://www.example.com/callback_url', {my_id: 10})
File without changes
data/lib/pricesphere.rb CHANGED
@@ -2,6 +2,7 @@ require 'pricesphere/version'
2
2
  require 'pricesphere/error'
3
3
  require 'pricesphere/base'
4
4
  require 'pricesphere/product'
5
+ require 'pricesphere/watch'
5
6
  module Pricesphere
6
7
 
7
8
  def self.base_url
@@ -1,3 +1,3 @@
1
1
  module Pricesphere
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,29 @@
1
+ module Pricesphere
2
+ class Watch < Base
3
+
4
+ def register(product_id, webhook_path, callback_params = {})
5
+ uri = URI.parse(Pricesphere.base_url)
6
+ http = Net::HTTP.new(uri.host, uri.port)
7
+ if Pricesphere.base_url =~ /\Ahttps:/
8
+ http.use_ssl = true
9
+ end
10
+
11
+ request = Net::HTTP::Post.new("/api/#{@version}/watches")
12
+ request.add_field('Content-Type', 'application/json')
13
+ request.body = {
14
+ watch: {
15
+ product_id: product_id,
16
+ webhook_path: webhook_path,
17
+ webhook_attributes: callback_params.to_json
18
+ },
19
+ token: @api_key
20
+ }.to_json
21
+
22
+ response = http.request(request)
23
+ end
24
+
25
+ private
26
+
27
+
28
+ end
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pricesphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris MacNaughton
@@ -66,12 +66,14 @@ files:
66
66
  - LICENSE.txt
67
67
  - README.md
68
68
  - Rakefile
69
- - examples/example.rb
69
+ - examples/create_watch.rb
70
+ - examples/product_search.rb
70
71
  - lib/pricesphere.rb
71
72
  - lib/pricesphere/base.rb
72
73
  - lib/pricesphere/error.rb
73
74
  - lib/pricesphere/product.rb
74
75
  - lib/pricesphere/version.rb
76
+ - lib/pricesphere/watch.rb
75
77
  - pricesphere.gemspec
76
78
  homepage: ''
77
79
  licenses: