Class: SynapsePayRest::PublicKey
- Inherits:
-
Object
- Object
- SynapsePayRest::PublicKey
- Defined in:
- lib/synapse_pay_rest/models/client/issue_public_key.rb
Overview
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.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#client_obj_id ⇒ Object
readonly
Returns the value of attribute client_obj_id.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#expires_in ⇒ Object
readonly
Returns the value of attribute expires_in.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Class Method Summary collapse
-
.from_response(response) ⇒ Object
Creates a client public key from a response hash.
-
.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") ⇒ SynapsePayRest::PublicKey
Issues public key for client.
Instance Method Summary collapse
-
#initialize(**options) ⇒ PublicKey
constructor
A new instance of PublicKey.
Constructor Details
#initialize(**options) ⇒ PublicKey
Do not call directly. Use PublicKey.issue or other class method to instantiate via API action.
Returns a new instance of PublicKey.
42 43 44 |
# File 'lib/synapse_pay_rest/models/client/issue_public_key.rb', line 42 def initialize(**) .each { |key, value| instance_variable_set("@#{key}", value) } end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/synapse_pay_rest/models/client/issue_public_key.rb', line 7 def client @client end |
#client_obj_id ⇒ Object (readonly)
Returns the value of attribute client_obj_id.
7 8 9 |
# File 'lib/synapse_pay_rest/models/client/issue_public_key.rb', line 7 def client_obj_id @client_obj_id end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
7 8 9 |
# File 'lib/synapse_pay_rest/models/client/issue_public_key.rb', line 7 def expires_at @expires_at end |
#expires_in ⇒ Object (readonly)
Returns the value of attribute expires_in.
7 8 9 |
# File 'lib/synapse_pay_rest/models/client/issue_public_key.rb', line 7 def expires_in @expires_in end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
7 8 9 |
# File 'lib/synapse_pay_rest/models/client/issue_public_key.rb', line 7 def public_key @public_key end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
7 8 9 |
# File 'lib/synapse_pay_rest/models/client/issue_public_key.rb', line 7 def scope @scope end |
Class Method Details
.from_response(response) ⇒ Object
Shouldn’t need to call this directly.
Creates a client public key from a response hash.
12 13 14 15 16 17 18 19 20 21 22 |
# 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") ⇒ SynapsePayRest::PublicKey
Issues public key for client.
31 32 33 34 35 36 37 |
# 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 |