layer-ruby 0.2.0 → 0.3.0

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: e7272a2505f0eeb66b69d0420d6f3a69ffc85edc
4
- data.tar.gz: 699b31ddf54ee940cf8889e3242b1b8d13833471
3
+ metadata.gz: 1175f3c645d381961648fee03212ff4148a4cce7
4
+ data.tar.gz: 57265f20d7c15ff918cd4e96b34c0211b1b8c488
5
5
  SHA512:
6
- metadata.gz: 8f2a3055d5272da8e7661868593f713cfc8d261ae789d3897714a9c5efcbed3c8191482183492c134284aa26d7eb1e063db57b22b49530554ad2d702e824879f
7
- data.tar.gz: c1bbc99b6ebcc2f81ac374284859d434709708ec584f9229f20a6d1855d32d011647e56d4b84c43c99131eec348d74be134fa23e9a0fd02181095bef6a171716
6
+ metadata.gz: 419b39243567daeaca8e3b18ede67330b460f8dd478b4851cb1afb6e4529af84f33807b618909e66d5e477caf9c9c01c25d77326a4cef8a2cad3c4b0cbe0d726
7
+ data.tar.gz: e9a09eb831bd7759f177397c8e9a9e9fd301c793f833dd68a9a2367d7d27156a282d5add4371b6dddbb5a2d58062a7c45dab8ca567440f15994b0e9417021160
data/README.md CHANGED
@@ -59,7 +59,7 @@ conversation = Layer::Conversation.find('CONVERSATION_ID_HERE')
59
59
  conversation.messages.create({ sender: { name: 'Server' }, parts: [{ body: 'Hello!', mime_type: 'text/plain' }])
60
60
  ```
61
61
 
62
- ### Sending Messages
62
+ ### Sending Announcements
63
63
 
64
64
  You can send a announcements like this:
65
65
 
@@ -1,4 +1,5 @@
1
1
  require 'rest-client'
2
+ require 'securerandom'
2
3
 
3
4
  module Layer
4
5
  class Client
@@ -16,12 +17,16 @@ module Layer
16
17
  def configure
17
18
  yield self
18
19
  end
20
+
21
+ def normalize_id(id)
22
+ id.to_s.split('/').last
23
+ end
19
24
  end
20
25
 
21
26
  attr_reader :app_id, :token
22
27
 
23
28
  def initialize(app_id = self.class.app_id, token = self.class.token)
24
- @app_id = app_id
29
+ @app_id = self.class.normalize_id(app_id)
25
30
  @token = token
26
31
  end
27
32
 
@@ -61,7 +66,8 @@ module Layer
61
66
  headers = {
62
67
  'Authorization' => "Bearer #{token}",
63
68
  'Accept' => 'application/vnd.layer+json; version=1.0',
64
- 'Content-Type' => 'application/json'
69
+ 'Content-Type' => 'application/json',
70
+ 'If-None-Match' => SecureRandom.uuid
65
71
  }.merge(headers)
66
72
 
67
73
  payload = payload.to_json
@@ -4,6 +4,7 @@ module Layer
4
4
 
5
5
  module ClassMethods
6
6
  def delete(id, client = self.client)
7
+ id = Layer::Client.normalize_id(id)
7
8
  client.delete("#{url}/#{id}")
8
9
  end
9
10
  end
@@ -4,6 +4,7 @@ module Layer
4
4
 
5
5
  module ClassMethods
6
6
  def find(id, client = self.client)
7
+ id = Layer::Client.normalize_id(id)
7
8
  response = client.get("#{url}/#{id}")
8
9
  from_response(response, client)
9
10
  end
@@ -21,4 +22,3 @@ module Layer
21
22
  end
22
23
  end
23
24
  end
24
-
@@ -1,3 +1,3 @@
1
1
  module Layer
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: layer-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benedikt Deicke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-22 00:00:00.000000000 Z
11
+ date: 2015-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client