Class: Shipay::Client
Overview
Class to hold client authetication data
Instance Attribute Summary collapse
-
#access_key ⇒ Object
readonly
Returns the value of attribute access_key.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#default ⇒ Object
Returns the value of attribute default.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(**options) ⇒ Client
constructor
Initialize Client instance.
-
#to_h ⇒ Hash
Convert Client instance to hash.
Constructor Details
#initialize(**options) ⇒ Client
Initialize Client instance
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/shipay/authenticator.rb', line 25 def initialize(**) begin @secret_key = .fetch(:secret_key, Shipay.secret_key) @access_key = .fetch(:access_key, Shipay.access_key) @client_id = .fetch(:client_id) @key = Shipay::Util.to_sym(.fetch(:key, Shipay.default_client_key )) @default = .fetch(:default, true) @type = .fetch(:type, :pdv) raise ParamError.new("Incorrect client type, must be one of #{CLIENT_TYPES}", :type, "Symbol") unless CLIENT_TYPES.include? @type rescue KeyError => e raise ParamError.new("Missing data for credentials: #{e.key}, (#{e.})", "Credentials", "Symbol or String") unless CLIENT_TYPES.include? @type end end |
Instance Attribute Details
#access_key ⇒ Object (readonly)
Returns the value of attribute access_key.
11 12 13 |
# File 'lib/shipay/authenticator.rb', line 11 def access_key @access_key end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
11 12 13 |
# File 'lib/shipay/authenticator.rb', line 11 def client_id @client_id end |
#default ⇒ Object
Returns the value of attribute default.
12 13 14 |
# File 'lib/shipay/authenticator.rb', line 12 def default @default end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/shipay/authenticator.rb', line 11 def key @key end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
11 12 13 |
# File 'lib/shipay/authenticator.rb', line 11 def secret_key @secret_key end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/shipay/authenticator.rb', line 11 def type @type end |
Instance Method Details
#to_h ⇒ Hash
Convert Client instance to hash
44 45 46 47 48 49 50 51 |
# File 'lib/shipay/authenticator.rb', line 44 def to_h { secret_key: @secret_key, access_key: @access_key, client_id: @client_id, key: @key } end |