Class: Io::Flow::V0::Clients::PublicKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ PublicKeys

Returns a new instance of PublicKeys.



2495
2496
2497
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2495

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#get(organization, incoming = {}) ⇒ Object

Returns your public keys



2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2500

def get(organization, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }),
    :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer),
    :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer),
    :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "-created_at" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/encryption/keys").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::PublicKey.new(x) }
end

#get_latest(organization) ⇒ Object

Return the latest public key for an organization



2514
2515
2516
2517
2518
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2514

def get_latest(organization)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  r = @client.request("/#{CGI.escape(organization)}/encryption/keys/latest").get
  ::Io::Flow::V0::Models::PublicKey.new(r)
end