class SynapsePayRest::PublicKey

Represents a public key record and holds methods for getting public key instances from API calls. This is built on top of the SynapsePayRest::Client class and is intended to make it easier to use the API without knowing payload formats or knowledge of REST.

Attributes

client[R]
client_obj_id[R]
expires_at[R]
expires_in[R]
public_key[R]
scope[R]

Public Class Methods

from_response(response) click to toggle source

Creates a client public key from a response hash. @note Shouldn't need to call this directly.

# File lib/synapse_pay_rest/models/client/issue_public_key.rb, line 12
def from_response(response)
  args = {
    client:                    response['client'],
    client_obj_id:             response['public_key_obj']['client_obj_id'],
    expires_at:                response['public_key_obj']['expires_at'],
    expires_in:                response['public_key_obj']['expires_in'],
    public_key:                response['public_key_obj']['public_key'],
    scope:                     response['public_key_obj']['scope']
  }
  self.new(args)
end
issue(client:, scope: "OAUTH|POST,USERS|POST,USERS|GET,USER|GET,USER|PATCH,SUBSCRIPTIONS|GET,SUBSCRIPTIONS|POST,SUBSCRIPTION|GET,SUBSCRIPTION|PATCH,CLIENT|REPORTS,CLIENT|CONTROLS") click to toggle source

Issues public key for client.

@param client [SynapsePayRest::Client]
@param scope [String]

@raise [SynapsePayRest::Error]

@return [SynapsePayRest::PublicKey] new instance corresponding to same API record
# File lib/synapse_pay_rest/models/client/issue_public_key.rb, line 31
def issue(client:, scope: "OAUTH|POST,USERS|POST,USERS|GET,USER|GET,USER|PATCH,SUBSCRIPTIONS|GET,SUBSCRIPTIONS|POST,SUBSCRIPTION|GET,SUBSCRIPTION|PATCH,CLIENT|REPORTS,CLIENT|CONTROLS")
  raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client)
  raise ArgumentError, 'scope must be a String' unless scope.is_a?(String)

  response = client.client_endpoint.issue_public_key(scope: scope)
  from_response(response)
end
new(**options) click to toggle source

@note Do not call directly. Use PublicKey.issue or other class method

to instantiate via API action.
# File lib/synapse_pay_rest/models/client/issue_public_key.rb, line 42
def initialize(**options)
  options.each { |key, value| instance_variable_set("@#{key}", value) }
end