Class: DuoApi::Accounts
Overview
Duo Accounts API (duo.com/docs/accountsapi)
Constant Summary
Constants inherited from DuoApi
BACKOFF_FACTOR, INITIAL_BACKOFF_WAIT_SECS, MAX_BACKOFF_WAIT_SECS, VERSION
Instance Attribute Summary
Attributes inherited from DuoApi
Instance Method Summary collapse
-
#admin_api(child_account_id:) ⇒ Object
Child Account Admin API Wrapper.
- #create_child_account(name:) ⇒ Object
- #delete_child_account(account_id:) ⇒ Object
-
#get_child_accounts ⇒ Object
Accounts API.
Methods inherited from DuoApi
#delete, #get, #get_all, #get_image, #initialize, #post, #put, #request
Constructor Details
This class inherits a constructor from DuoApi
Instance Method Details
#admin_api(child_account_id:) ⇒ Object
Child Account Admin API Wrapper
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/duo_api/accounts.rb', line 33 def admin_api(child_account_id:) child_account = get_child_accounts.select{ |a| a[:account_id] == child_account_id }.first raise(ChildAccountError, "Child account #{child_account_id} not found") unless child_account client = DuoApi::Admin.new(@ikey, @skey, child_account[:api_hostname], @proxy_str, ca_file: @ca_file, default_params: { account_id: child_account_id }) # Additional Child Account Admin API Methods # # Note: # - These are enabled by support request only # - They can only be called by the DuoApi::Admin instance returned by this wrapper method # - account_id is required for each of these, but it is provided by the client default_params # client.instance_eval do def get_edition get('/admin/v1/billing/edition')[:response] end def set_edition(edition:) params = { edition: edition } post('/admin/v1/billing/edition', params)[:response] end def get_telephony_credits get('/admin/v1/billing/telephony_credits')[:response] end def set_telephony_credits(credits:) params = { credits: credits } post('/admin/v1/billing/telephony_credits', params)[:response] end end client end |
#create_child_account(name:) ⇒ Object
20 21 22 23 |
# File 'lib/duo_api/accounts.rb', line 20 def create_child_account(name:) params = { name: name } post('/accounts/v1/account/create', params)[:response] end |
#delete_child_account(account_id:) ⇒ Object
25 26 27 28 |
# File 'lib/duo_api/accounts.rb', line 25 def delete_child_account(account_id:) params = { account_id: account_id } post('/accounts/v1/account/delete', params)[:response] end |
#get_child_accounts ⇒ Object
Accounts API
16 17 18 |
# File 'lib/duo_api/accounts.rb', line 16 def get_child_accounts post('/accounts/v1/account/list')[:response] end |