Class: KaChing::ApiV1::Tenants
- Inherits:
-
Object
- Object
- KaChing::ApiV1::Tenants
- Extended by:
- Forwardable
- Defined in:
- lib/ka_ching/api_v1/tenants.rb
Overview
Tenants Endpoint for the KaChing API V1
Instance Method Summary collapse
-
#active(page: 1) {|res| ... } ⇒ Array<Hash>
Get all active tenants paginated.
-
#all(page: 1, per_page: 1000) {|res| ... } ⇒ Array<Hash>
Get all tenants paginated.
-
#inactive(page: 1) {|res| ... } ⇒ Array<Hash>
Get all inactive tenants paginated.
-
#initialize(conn:, api_url:) ⇒ Tenants
constructor
A new instance of Tenants.
Constructor Details
#initialize(conn:, api_url:) ⇒ Tenants
Returns a new instance of Tenants.
13 14 15 16 |
# File 'lib/ka_ching/api_v1/tenants.rb', line 13 def initialize(conn:, api_url:) @conn = conn @api_url = api_url end |
Instance Method Details
#active(page: 1) {|res| ... } ⇒ Array<Hash>
Get all active tenants paginated
42 43 44 45 46 47 48 49 50 |
# File 'lib/ka_ching/api_v1/tenants.rb', line 42 def active(page: 1) active_url = build_url res = get("#{active_url}/active") do |req| req.headers['Content-Type'] = 'application/json' req.body = { page: page, per_page: per_page }.to_json end yield res if block_given? JSON.parse(res.body) end |
#all(page: 1, per_page: 1000) {|res| ... } ⇒ Array<Hash>
Get all tenants paginated
25 26 27 28 29 30 31 32 33 |
# File 'lib/ka_ching/api_v1/tenants.rb', line 25 def all(page: 1, per_page: 1000) all_url = build_url res = get("#{all_url}/all") do |req| req.headers['Content-Type'] = 'application/json' req.body = { page: page, per_page: per_page }.to_json end yield res if block_given? JSON.parse(res.body) end |
#inactive(page: 1) {|res| ... } ⇒ Array<Hash>
Get all inactive tenants paginated
59 60 61 62 63 64 65 66 67 |
# File 'lib/ka_ching/api_v1/tenants.rb', line 59 def inactive(page: 1) inactive_url = build_url res = get("#{inactive_url}/inactive}") do |req| req.headers['Content-Type'] = 'application/json' req.body = { page: page, per_page: per_page }.to_json end yield res if block_given? JSON.parse(res.body) end |