pusher-platform 0.10.0 → 0.11.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
  SHA256:
3
- metadata.gz: 9cc62681eb9e885dac40f75a5a461cacf237575c3f04933818d1172e1016866a
4
- data.tar.gz: 8f3772d45bfece5711842230e3061b2d726b94688685ad283eb28215d0fa22df
3
+ metadata.gz: 1f84b41f7509bd68caf5e76e41faf121691296bc24a8b99cb8d056d138388d98
4
+ data.tar.gz: c8a9f55dec5a342636ed729f2258e31bae2a7df8239e625fc3dcee76509adf09
5
5
  SHA512:
6
- metadata.gz: 1d297f244c8709f56adb979818e63c8b07ea70f8baddbb2e8e19fad7ae1f068ae3d45068e801a255662fd69020c67f1ccd44c5a7aa94cba2250684c12021f935
7
- data.tar.gz: d15e3e5be0a907a210e66eb1617b45fcd7fbcf8da82bcc11894f9e61d6d909817b786a8624e625954441eb7ae5490c162b14eabab9402333abec9e1d2d90eca0
6
+ metadata.gz: 5edfb6584275d69a78b537732e19d9b95eaf2e5ec60229dccf881a689db73d122e3077933b084e5376936e57e9c3ed5c7cc6329feceda5bcd4b00489992efa7b
7
+ data.tar.gz: 62453f3374b3d0d69187e53edcf868150985cda5edd957ea366787613060b1d420226895fa6bb4cabb9cbcefbba144cbabd37bf7f2ab531a174053f3b7615dfd
@@ -1,5 +1,6 @@
1
1
  require 'excon'
2
2
  require 'json'
3
+ require_relative './sdk_info'
3
4
  require_relative './error_response'
4
5
  require_relative './error'
5
6
 
@@ -7,6 +8,7 @@ module PusherPlatform
7
8
  class BaseClient
8
9
  def initialize(options)
9
10
  raise PusherPlatform::Error.new("Unspecified host") if options[:host].nil?
11
+ raise PusherPlatform::Error.new("Unspecified sdk_info") if options[:sdk_info].nil?
10
12
  port_string = options[:port] || ''
11
13
  host_string = "https://#{options[:host]}#{port_string}"
12
14
  @connection = Excon.new(host_string)
@@ -14,17 +16,16 @@ module PusherPlatform
14
16
  @instance_id = options[:instance_id]
15
17
  @service_name = options[:service_name]
16
18
  @service_version = options[:service_version]
19
+
20
+ @sdk_info = options[:sdk_info]
17
21
  end
18
22
 
19
23
  def request(options)
20
24
  raise PusherPlatform::Error.new("Unspecified request method") if options[:method].nil?
21
25
  raise PusherPlatform::Error.new("Unspecified request path") if options[:path].nil?
22
26
 
23
- headers = if options[:headers]
24
- options[:headers].dup
25
- else
26
- {}
27
- end
27
+ headers = @sdk_info.headers
28
+ headers.merge(options[:headers].dup) if options[:headers]
28
29
 
29
30
  if options[:jwt]
30
31
  headers["Authorization"] = "Bearer #{options[:jwt]}"
@@ -1,6 +1,7 @@
1
1
  require_relative './authenticator'
2
2
  require_relative './base_client'
3
3
  require_relative './common'
4
+ require_relative './sdk_info'
4
5
  require_relative './error_response'
5
6
  require_relative './error'
6
7
 
@@ -14,6 +15,10 @@ module PusherPlatform
14
15
  raise PusherPlatform::Error.new("No key provided") if options[:key].nil?
15
16
  raise PusherPlatform::Error.new("No service name provided") if options[:service_name].nil?
16
17
  raise PusherPlatform::Error.new("No service version provided") if options[:service_version].nil?
18
+ if options[:sdk_info].nil? && options[:client].nil?
19
+ raise PusherPlatform::Error.new("You must provide either an SDKInfo or BaseClient instance via sdk_info or client")
20
+ end
21
+
17
22
  locator = options[:locator]
18
23
  @service_name = options[:service_name]
19
24
  @service_version = options[:service_version]
@@ -38,7 +43,8 @@ module PusherPlatform
38
43
  port: options[:port],
39
44
  instance_id: @instance_id,
40
45
  service_name: @service_name,
41
- service_version: @service_version
46
+ service_version: @service_version,
47
+ sdk_info: options[:sdk_info]
42
48
  )
43
49
  end
44
50
 
@@ -0,0 +1,26 @@
1
+ require_relative './error'
2
+
3
+ module PusherPlatform
4
+ class SDKInfo
5
+ attr_reader :product_name, :version, :language, :platform, :headers
6
+
7
+ def initialize(options)
8
+ raise Error.new('No product_name provided to SDKInfo') if options[:product_name].nil?
9
+ raise Error.new('No version provided to SDKInfo') if options[:version].nil?
10
+
11
+ @product_name = options[:product_name]
12
+ @version = options[:version]
13
+
14
+ @platform = options[:platform] || 'server'
15
+ @language = 'ruby'
16
+
17
+ @headers = {
18
+ "X-SDK-Product" => @product_name,
19
+ "X-SDK-Version" => @version,
20
+ "X-SDK-Language" => @language,
21
+ "X-SDK-Platform" => @platform
22
+ }
23
+ end
24
+
25
+ end
26
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pusher-platform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pusher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-17 00:00:00.000000000 Z
11
+ date: 2018-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -52,6 +52,7 @@ files:
52
52
  - lib/pusher-platform/error.rb
53
53
  - lib/pusher-platform/error_response.rb
54
54
  - lib/pusher-platform/instance.rb
55
+ - lib/pusher-platform/sdk_info.rb
55
56
  homepage:
56
57
  licenses:
57
58
  - MIT