layer-ruby 0.5.1 → 0.5.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 +2 -2
- data/lib/layer/client/platform.rb +1 -1
- data/lib/layer/client/rest.rb +2 -2
- data/lib/layer/content.rb +9 -4
- data/lib/layer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61e305d86bef553cf007ea06b53265fe7f8ad58f
|
4
|
+
data.tar.gz: ac7d9f4352409840b170349e7a12922b9cac2d6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16d8ab1eecd12225300f39660ed1d14fcea99a0ee158f406ab96921a7971b73c1d4f377d43f350b92780a7a71072985d61170ae6d4630679a6745ae19ae675c4
|
7
|
+
data.tar.gz: d15bad52453b3877d5cdc7e7086dd27fe811cb819d2af2b347d05d01cfe35ff79c96be4aeb25b681c4a81819bd262019b02fb55fbdcc51188efa04f858e3e270
|
data/README.md
CHANGED
@@ -39,10 +39,10 @@ end
|
|
39
39
|
|
40
40
|
### Using the gem with multiple applications at once
|
41
41
|
|
42
|
-
It's possible to create a new instance of `Layer::Client` and passing both the app id and the token to the initializer:
|
42
|
+
It's possible to create a new instance of `Layer::Client::Platform` and passing both the app id and the token to the initializer:
|
43
43
|
|
44
44
|
```ruby
|
45
|
-
|
45
|
+
platform_client = Layer::Client::Platform.new('YOUR_APP_ID_HERE', 'YOUR_PLATFORM_TOKEN_HERE')
|
46
46
|
```
|
47
47
|
|
48
48
|
The client will not use any global configuration. You can pass the client as a second parameter to any operations (`create`, `find`) described above.
|
data/lib/layer/client/rest.rb
CHANGED
@@ -15,7 +15,7 @@ module Layer
|
|
15
15
|
|
16
16
|
attr_reader :token, :app_id, :block
|
17
17
|
|
18
|
-
def initialize(app_id =
|
18
|
+
def initialize(app_id = Layer::Client.app_id, &block)
|
19
19
|
@app_id = self.class.normalize_id(app_id)
|
20
20
|
@block = block
|
21
21
|
authenticate
|
@@ -28,7 +28,7 @@ module Layer
|
|
28
28
|
headers['Authorization'] ||= "Layer session-token=\"#{token}\""
|
29
29
|
|
30
30
|
super
|
31
|
-
rescue Layer::Exceptions::
|
31
|
+
rescue Layer::Exceptions::AuthenticationRequired => exception
|
32
32
|
authenticate(exception.response_json['data']['nonce'])
|
33
33
|
retry
|
34
34
|
end
|
data/lib/layer/content.rb
CHANGED
@@ -5,7 +5,7 @@ module Layer
|
|
5
5
|
# message = Layer::Message.create({
|
6
6
|
# sender: { name: 'Server' },
|
7
7
|
# parts: [
|
8
|
-
# {
|
8
|
+
# { content: content, mime_type: 'image/png' }
|
9
9
|
# ]
|
10
10
|
# })
|
11
11
|
#
|
@@ -19,12 +19,12 @@ module Layer
|
|
19
19
|
# @!parse extend Layer::Operations::Find::ClassMethods
|
20
20
|
|
21
21
|
def self.create(mime_type, file, client = self.client)
|
22
|
-
response = client.post(url, {},
|
22
|
+
response = client.post(url, {}, {
|
23
23
|
'Upload-Content-Type' => mime_type,
|
24
24
|
'Upload-Content-Length' => file.size
|
25
25
|
})
|
26
26
|
|
27
|
-
attributes = response.merge('size' => file.size)
|
27
|
+
attributes = response.merge('size' => file.size, 'mime_type' => mime_type)
|
28
28
|
|
29
29
|
from_response(attributes, client).tap do |content|
|
30
30
|
content.upload(file)
|
@@ -43,8 +43,13 @@ module Layer
|
|
43
43
|
attributes['refresh_url'] || "#{self.class.url}/#{Layer::Client.normalize_id(id)}"
|
44
44
|
end
|
45
45
|
|
46
|
+
def as_json(*args)
|
47
|
+
{ id: id, size: size }
|
48
|
+
end
|
49
|
+
|
46
50
|
def to_json(*args)
|
47
|
-
|
51
|
+
as_json.to_json(*args)
|
48
52
|
end
|
53
|
+
|
49
54
|
end
|
50
55
|
end
|
data/lib/layer/version.rb
CHANGED
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.5.
|
4
|
+
version: 0.5.2
|
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-
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|