Class: Alcatraz::Client::Connection
- Inherits:
-
Object
- Object
- Alcatraz::Client::Connection
- Defined in:
- lib/alcatraz/client/connection.rb
Instance Method Summary collapse
- #authorize_data_for_client!(data_or_id, client_or_public_key) ⇒ Object
- #create_client!(name, enable_two_factor_auth = false) ⇒ Object
- #deauthorize_data_for_client!(data_or_id, client_or_public_key) ⇒ Object
- #destroy_client!(id) ⇒ Object
- #disable_two_factor_auth!(id) ⇒ Object
- #enable_two_factor_auth!(id) ⇒ Object
- #get_card(id) ⇒ Object
- #get_data(id) ⇒ Object
-
#initialize(options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #store_card!(params) ⇒ Object
- #store_data!(params) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Connection
Returns a new instance of Connection.
8 9 10 11 12 13 14 |
# File 'lib/alcatraz/client/connection.rb', line 8 def initialize( = {}) = ::Alcatraz::Client..merge() Configuration::VALID_OPTIONS.each do |key| public_send("#{key}=", [key]) end end |
Instance Method Details
#authorize_data_for_client!(data_or_id, client_or_public_key) ⇒ Object
63 64 65 66 67 |
# File 'lib/alcatraz/client/connection.rb', line 63 def (data_or_id, client_or_public_key) data_id = unwrap_to_id data_or_id public_key = unwrap_to_key client_or_public_key post("/secure_data/#{data_id}/authorizations", public_key: public_key).success? end |
#create_client!(name, enable_two_factor_auth = false) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/alcatraz/client/connection.rb', line 32 def create_client!(name, enable_two_factor_auth = false) response = post('/api_clients', api_client: {name: name, enable_two_factor_auth: enable_two_factor_auth}) if response.success? response.body.api_client else nil end end |
#deauthorize_data_for_client!(data_or_id, client_or_public_key) ⇒ Object
69 70 71 72 73 |
# File 'lib/alcatraz/client/connection.rb', line 69 def (data_or_id, client_or_public_key) data_id = unwrap_to_id data_or_id public_key = unwrap_to_key client_or_public_key delete("/secure_data/#{data_id}/authorizations/#{public_key}") end |
#destroy_client!(id) ⇒ Object
41 42 43 |
# File 'lib/alcatraz/client/connection.rb', line 41 def destroy_client!(id) delete("/api_clients/#{id}") end |
#disable_two_factor_auth!(id) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/alcatraz/client/connection.rb', line 54 def disable_two_factor_auth!(id) response = put("/api_clients/#{id}/disable_two_factor_auth") if response.success? response.body.api_client else nil end end |
#enable_two_factor_auth!(id) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/alcatraz/client/connection.rb', line 45 def enable_two_factor_auth!(id) response = put("/api_clients/#{id}/enable_two_factor_auth") if response.success? response.body.api_client else nil end end |
#get_card(id) ⇒ Object
16 17 18 |
# File 'lib/alcatraz/client/connection.rb', line 16 def get_card(id) parse_response_to_secure_object(get("/cards/#{id}")) end |
#get_data(id) ⇒ Object
24 25 26 |
# File 'lib/alcatraz/client/connection.rb', line 24 def get_data(id) parse_response_to_secure_object(get("/secure_data/#{id}")) end |
#store_card!(params) ⇒ Object
20 21 22 |
# File 'lib/alcatraz/client/connection.rb', line 20 def store_card!(params) parse_response_to_secure_object(post('/cards', params)) end |
#store_data!(params) ⇒ Object
28 29 30 |
# File 'lib/alcatraz/client/connection.rb', line 28 def store_data!(params) parse_response_to_secure_object(post('/secure_data', params)) end |