Class: PusherPlatform::Instance
- Inherits:
-
Object
- Object
- PusherPlatform::Instance
- Defined in:
- lib/pusher-platform/instance.rb
Instance Method Summary collapse
- #authenticate(auth_payload, options) ⇒ Object
- #authenticate_with_refresh_token(auth_payload, options) ⇒ Object
- #authenticate_with_refresh_token_and_request(auth_payload, options) ⇒ Object
- #authenticate_with_request(request, options) ⇒ Object
- #generate_access_token(options) ⇒ Object
-
#initialize(options) ⇒ Instance
constructor
A new instance of Instance.
- #request(options) ⇒ Object
Constructor Details
#initialize(options) ⇒ Instance
Returns a new instance of Instance.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pusher-platform/instance.rb', line 13 def initialize() raise PusherPlatform::Error.new("No instance locator provided") if [:locator].nil? raise PusherPlatform::Error.new("No key provided") if [:key].nil? raise PusherPlatform::Error.new("No service name provided") if [:service_name].nil? raise PusherPlatform::Error.new("No service version provided") if [:service_version].nil? if [:sdk_info].nil? && [:client].nil? raise PusherPlatform::Error.new("You must provide either an SDKInfo or BaseClient instance via sdk_info or client") end locator = [:locator] @service_name = [:service_name] @service_version = [:service_version] key_parts = [:key].match(/^([^:]+):(.+)$/) raise PusherPlatform::Error.new("Invalid key") if key_parts.nil? @key_id = key_parts[1] @key_secret = key_parts[2] split_locator = locator.split(':') @platform_version = split_locator[0] @cluster = split_locator[1] @instance_id = split_locator[2] @client = if [:client] [:client] else BaseClient.new( host: [:host] || "#{@cluster}.#{HOST_BASE}", port: [:port], instance_id: @instance_id, service_name: @service_name, service_version: @service_version, sdk_info: [:sdk_info] ) end @authenticator = Authenticator.new(@instance_id, @key_id, @key_secret) end |
Instance Method Details
#authenticate(auth_payload, options) ⇒ Object
58 59 60 |
# File 'lib/pusher-platform/instance.rb', line 58 def authenticate(auth_payload, ) @authenticator.authenticate(auth_payload, ) end |
#authenticate_with_refresh_token(auth_payload, options) ⇒ Object
66 67 68 |
# File 'lib/pusher-platform/instance.rb', line 66 def authenticate_with_refresh_token(auth_payload, ) @authenticator.authenticate_with_refresh_token(auth_payload, ) end |
#authenticate_with_refresh_token_and_request(auth_payload, options) ⇒ Object
70 71 72 |
# File 'lib/pusher-platform/instance.rb', line 70 def authenticate_with_refresh_token_and_request(auth_payload, ) @authenticator.authenticate_with_refresh_token_and_request(auth_payload, ) end |
#authenticate_with_request(request, options) ⇒ Object
62 63 64 |
# File 'lib/pusher-platform/instance.rb', line 62 def authenticate_with_request(request, ) @authenticator.authenticate_with_request(request, ) end |
#generate_access_token(options) ⇒ Object
74 75 76 |
# File 'lib/pusher-platform/instance.rb', line 74 def generate_access_token() @authenticator.generate_access_token() end |
#request(options) ⇒ Object
54 55 56 |
# File 'lib/pusher-platform/instance.rb', line 54 def request() @client.request() end |