layer-ruby 0.5.1 → 0.5.2

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: bdfce84c680a8d8cb3b853677f13e13493307e10
4
- data.tar.gz: 30b977d766b20443b3cabf18ace92571b3c18e32
3
+ metadata.gz: 61e305d86bef553cf007ea06b53265fe7f8ad58f
4
+ data.tar.gz: ac7d9f4352409840b170349e7a12922b9cac2d6d
5
5
  SHA512:
6
- metadata.gz: f8fb25324626955baab552f6c6a6f92d9c00d97aa4edce59a7bf15bcaf81bee4d6128329aa70112d8b370a59181532590be06f29b78ec9d6021a9ba1976aa1e5
7
- data.tar.gz: 6068557ad8a9f9653b96da24a8b93eb88c22ad2053c3a25e083367f8599c0d1e3313731a7aa9306c4275bd61dd183c391db57e2c8197883798d26ba102734011
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
- client = Layer::Client.new('YOUR_APP_ID_HERE', 'YOUR_PLATFORM_TOKEN_HERE')
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.
@@ -4,7 +4,7 @@ module Layer
4
4
 
5
5
  attr_reader :app_id, :token
6
6
 
7
- def initialize(app_id = self.class.app_id, token = self.class.token)
7
+ def initialize(app_id = Layer::Client.app_id, token = Layer::Client.token)
8
8
  @app_id = self.class.normalize_id(app_id)
9
9
  @token = token
10
10
  end
@@ -15,7 +15,7 @@ module Layer
15
15
 
16
16
  attr_reader :token, :app_id, :block
17
17
 
18
- def initialize(app_id = self.class.app_id, &block)
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::Exceptions::AuthenticationRequired => exception
31
+ rescue Layer::Exceptions::AuthenticationRequired => exception
32
32
  authenticate(exception.response_json['data']['nonce'])
33
33
  retry
34
34
  end
@@ -5,7 +5,7 @@ module Layer
5
5
  # message = Layer::Message.create({
6
6
  # sender: { name: 'Server' },
7
7
  # parts: [
8
- # { body: content.to_json, mime_type: content.mime_type }
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, {}, headers = {
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
- { id: id, size: size }.to_json(*args)
51
+ as_json.to_json(*args)
48
52
  end
53
+
49
54
  end
50
55
  end
@@ -1,3 +1,3 @@
1
1
  module Layer
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
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.5.1
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-25 00:00:00.000000000 Z
11
+ date: 2015-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client