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 +4 -4
- data/README.md +9 -4
- data/lib/pebble_timeline/api.rb +4 -1
- data/lib/pebble_timeline/pins.rb +10 -6
- data/lib/pebble_timeline/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ae2a05e63d6905acd6ff98edff0bde495c2b838
|
4
|
+
data.tar.gz: 05a46e7eabf8eeec8f53ea61e634a8037c2efddf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3e64dc07bea1d58a7125767627cffff896ab15c88a1d2cab2ac56ae1d9812296a9a67f8ea38dfbb9d2d3b85cc77b061f0c21f6e9cb13e98c25803b45f2b4074
|
7
|
+
data.tar.gz: ef3663e3defbe73dde4612a70bf023b2ebaca70ba3db898bff4786332253dc9e4c5c280116ee16711b78636db9ccdda46c0d54c6ba84e3d202decefbfc027197
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# PebbleTimeline
|
2
2
|
|
3
|
-
|
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
|
data/lib/pebble_timeline/api.rb
CHANGED
@@ -46,7 +46,10 @@ module PebbleTimeline
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def delete(path, params)
|
49
|
-
connection.delete
|
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)
|
data/lib/pebble_timeline/pins.rb
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
module PebbleTimeline
|
2
2
|
class Pins
|
3
|
-
def initialize(master,
|
3
|
+
def initialize(master, scope = 'shared', user_token = nil)
|
4
4
|
@master = master
|
5
|
-
@
|
5
|
+
@scope = scope
|
6
|
+
@user_token = user_token if @scope == 'user'
|
6
7
|
end
|
7
8
|
|
8
9
|
def create(params = {})
|
9
|
-
|
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
|
-
|
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
|
-
|
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
|