Class: KaChing::ApiV1::Admin
- Inherits:
-
Object
- Object
- KaChing::ApiV1::Admin
- Extended by:
- Forwardable
- Defined in:
- lib/ka_ching/api_v1/admin.rb
Overview
Admin Endpoint for the KaChing API V1
Instance Method Summary collapse
-
#create!(tenant_account_id:) {|Faraday::Response| ... } ⇒ Hash
creates a new tenant database.
-
#details(tenant_account_id:) {|Faraday::Response| ... } ⇒ Hash
gets the details of a tenant database.
-
#drop!(tenant_account_id:) {|Faraday::Response| ... } ⇒ Hash
drops a tenant database.
-
#initialize(conn:, api_url:) ⇒ Admin
constructor
A new instance of Admin.
-
#reset!(tenant_account_id:) {|res| ... } ⇒ Hash
resets a tenant database.
Constructor Details
#initialize(conn:, api_url:) ⇒ Admin
Returns a new instance of Admin.
13 14 15 16 |
# File 'lib/ka_ching/api_v1/admin.rb', line 13 def initialize(conn:, api_url:) @conn = conn @api_url = api_url end |
Instance Method Details
#create!(tenant_account_id:) {|Faraday::Response| ... } ⇒ Hash
creates a new tenant database
44 45 46 47 48 49 50 51 |
# File 'lib/ka_ching/api_v1/admin.rb', line 44 def create!(tenant_account_id:) res = post(build_url) do |req| req.headers['Content-Type'] = 'application/json' req.body = { tenant_account_id: tenant_account_id }.to_json end yield res if block_given? JSON.parse(res.body) end |
#details(tenant_account_id:) {|Faraday::Response| ... } ⇒ Hash
gets the details of a tenant database
26 27 28 29 30 31 32 33 |
# File 'lib/ka_ching/api_v1/admin.rb', line 26 def details(tenant_account_id:) admin_tenant_url = build_url(tenant_account_id: tenant_account_id) res = get(admin_tenant_url) do |req| req.headers['Content-Type'] = 'application/json' end yield res if block_given? JSON.parse(res.body) end |
#drop!(tenant_account_id:) {|Faraday::Response| ... } ⇒ Hash
drops a tenant database
78 79 80 81 82 83 84 85 |
# File 'lib/ka_ching/api_v1/admin.rb', line 78 def drop!(tenant_account_id:) res = delete(build_url) do |req| req.headers['Content-Type'] = 'application/json' req.body = { tenant_account_id: tenant_account_id }.to_json end yield res if block_given? JSON.parse(res.body) end |
#reset!(tenant_account_id:) {|res| ... } ⇒ Hash
resets a tenant database
60 61 62 63 64 65 66 67 |
# File 'lib/ka_ching/api_v1/admin.rb', line 60 def reset!(tenant_account_id:) reset_url = "#{build_url(tenant_account_id: tenant_account_id)}/reset" res = post(reset_url) do |req| req.headers['Content-Type'] = 'application/json' end yield res if block_given? JSON.parse(res.body) end |