pebble_timeline 0.0.1 → 0.0.2

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: fd338b2ea3b81ccb37288a2df5ce164e1926219f
4
- data.tar.gz: b5b88e380890c434034fe2895d2cdf44ceb24867
3
+ metadata.gz: 9ae2a05e63d6905acd6ff98edff0bde495c2b838
4
+ data.tar.gz: 05a46e7eabf8eeec8f53ea61e634a8037c2efddf
5
5
  SHA512:
6
- metadata.gz: 9cb9b9214a901fd0b97a5311e41ae3ad82b78292c66e174e5910b91bbefcd0c7e443bba1ff0a3182610261833898e02a47d51197109f47f0733628eb71532e72
7
- data.tar.gz: 97ccb85508bac62c0c094387d126b5a5099801babd18e0604115b14044c47680949590d3c09e3cb22ce35db176e87f49dc99c9fe1d76c768d88ed07fe89ff0f0
6
+ metadata.gz: e3e64dc07bea1d58a7125767627cffff896ab15c88a1d2cab2ac56ae1d9812296a9a67f8ea38dfbb9d2d3b85cc77b061f0c21f6e9cb13e98c25803b45f2b4074
7
+ data.tar.gz: ef3663e3defbe73dde4612a70bf023b2ebaca70ba3db898bff4786332253dc9e4c5c280116ee16711b78636db9ccdda46c0d54c6ba84e3d202decefbfc027197
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # PebbleTimeline
2
2
 
3
- TODO: Write a gem description
3
+ This is a wrapper for the Pebble Timeline API documented [here](http://developer.getpebble.com/guides/timeline/)
4
4
 
5
5
  ## Installation
6
6
 
@@ -24,11 +24,16 @@ Or install it yourself as:
24
24
  require 'pebble_timeline'
25
25
 
26
26
  api = PebbleTimeline::API.new(ENV['PEBBLE_TIMELINE_API_KEY'])
27
- pins = PebbleTimeline::Pins.new(api)
28
-
29
- pins.create(id: "test-1", topics: 'test', time: "2015-06-10T08:01:10.229Z", layout: { shortTitle: 'test 1' })
30
27
 
28
+ # Shared pins
29
+ pins = PebbleTimeline::Pins.new(api)
30
+ pins.create(id: "test-1", topics: 'test', time: "2015-06-10T08:01:10.229Z", layout: { type: 'genericPin', title: 'test 1' })
31
31
  pins.delete("test-1")
32
+
33
+ # User pins
34
+ user_pins = PebbleTimeline::Pins.new(api, 'user', USER_TOKEN)
35
+ user_pins.create(id: "test-1", time: "2015-06-12T16:42:00Z", layout: { type: 'genericPin', title: 'test 1' })
36
+ user_pins.delete("test-1")
32
37
  ```
33
38
 
34
39
  ## Contributing
@@ -46,7 +46,10 @@ module PebbleTimeline
46
46
  end
47
47
 
48
48
  def delete(path, params)
49
- connection.delete(resource_url(path), params)
49
+ connection.delete do |req|
50
+ req.url resource_url(path)
51
+ req.headers['X-User-Token'] = params.delete(:user_token) if params.has_key? :user_token
52
+ end
50
53
  end
51
54
 
52
55
  def resource_url(path)
@@ -1,20 +1,24 @@
1
1
  module PebbleTimeline
2
2
  class Pins
3
- def initialize(master, type = 'shared')
3
+ def initialize(master, scope = 'shared', user_token = nil)
4
4
  @master = master
5
- @type = type
5
+ @scope = scope
6
+ @user_token = user_token if @scope == 'user'
6
7
  end
7
8
 
8
9
  def create(params = {})
9
- @master.call("#{@type}/pins/#{params[:id]}", :put, params)
10
+ params.merge!(user_token: @user_token) if @user_token
11
+ @master.call("#{@scope}/pins/#{params[:id]}", :put, params)
10
12
  end
11
13
 
12
14
  def update(id, params = {})
13
- @master.call("#{@type}/pins/#{id}.json", :put, params)
15
+ params.merge!(user_token: @user_token) if @user_token
16
+ @master.call("#{@scope}/pins/#{id}.json", :put, params)
14
17
  end
15
18
 
16
- def delete(id)
17
- @master.call("#{@type}/pins/#{id}", :delete)
19
+ def delete(id, params = {})
20
+ params.merge!(user_token: @user_token) if @user_token
21
+ @master.call("#{@scope}/pins/#{id}", :delete, params)
18
22
  end
19
23
  end
20
24
  end
@@ -1,3 +1,3 @@
1
1
  module PebbleTimeline
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pebble_timeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salim Hbeiliny