Class: Bitly::API::Organization
- Inherits:
-
Object
- Object
- Bitly::API::Organization
- Includes:
- Base
- Defined in:
- lib/bitly/api/organization.rb
Overview
An Organization is the top level of the Bitly user hierarchy. Both Users and Groups live within an organization.
Defined Under Namespace
Classes: List
Instance Attribute Summary
Attributes included from Base
Class Method Summary collapse
-
.attributes ⇒ Array<Symbol>
organization.
-
.fetch(client:, organization_guid:) ⇒ Bitly::API::Organization
Retrieve an organization from the API.
-
.list(client:) ⇒ Bitly::API::Organization::List
Get a list of organizations from the API.
-
.time_attributes ⇒ Array<Symbol>
converted to ‘Time` objects.
Instance Method Summary collapse
- #groups ⇒ Bitly::API::Group::List
-
#initialize(data:, client:, response: nil) ⇒ Bitly::API::Organization
constructor
Creates a new ‘Bitly::API::Organization` object.
-
#shorten_counts ⇒ Bitly::API::ShortenCounts
Shorten counts by organization [‘GET /v4/organizations/organization_guid/shorten_counts`](dev.bitly.com/api-reference/#getOrganizationShortenCounts).
Methods included from Base
Constructor Details
#initialize(data:, client:, response: nil) ⇒ Bitly::API::Organization
Creates a new ‘Bitly::API::Organization` object
80 81 82 83 84 |
# File 'lib/bitly/api/organization.rb', line 80 def initialize(data:, client:, response: nil) assign_attributes(data) @client = client @response = response end |
Class Method Details
.attributes ⇒ Array<Symbol>
organization
57 58 59 |
# File 'lib/bitly/api/organization.rb', line 57 def self.attributes [:name, :guid, :is_active, :tier, :tier_family, :tier_display_name, :role, :bsds] end |
.fetch(client:, organization_guid:) ⇒ Bitly::API::Organization
Retrieve an organization from the API. It receives an authorized ‘Bitly::API::Client` object and an organization guid and uses it to
request the `/organizations/:organization_guid` endpoint.
[‘GET /v4/organizations/organization_guid`](dev.bitly.com/api-reference/#getOrganization)
50 51 52 53 |
# File 'lib/bitly/api/organization.rb', line 50 def self.fetch(client:, organization_guid:) response = client.request(path: "/organizations/#{organization_guid}") Organization.new(data: response.body, client: client, response: response) end |
.list(client:) ⇒ Bitly::API::Organization::List
Get a list of organizations from the API. It receives an authorized ‘Bitly::API::Client` object and uses it to request the `/organizations` endpoint. [`GET /v4/organizations`](dev.bitly.com/api-reference/#getOrganizations)
29 30 31 32 33 34 35 |
# File 'lib/bitly/api/organization.rb', line 29 def self.list(client:) response = client.request(path: '/organizations') organizations = response.body['organizations'].map do |org| Organization.new(data: org, client: client) end List.new(items: organizations, response: response) end |
.time_attributes ⇒ Array<Symbol>
converted to ‘Time` objects.
62 63 64 |
# File 'lib/bitly/api/organization.rb', line 62 def self.time_attributes [:created, :modified] end |
Instance Method Details
#groups ⇒ Bitly::API::Group::List
87 88 89 |
# File 'lib/bitly/api/organization.rb', line 87 def groups @groups ||= Group.list(client: @client, organization: self) end |
#shorten_counts ⇒ Bitly::API::ShortenCounts
Shorten counts by organization [‘GET /v4/organizations/organization_guid/shorten_counts`](dev.bitly.com/api-reference/#getOrganizationShortenCounts)
99 100 101 |
# File 'lib/bitly/api/organization.rb', line 99 def shorten_counts ShortenCounts.by_organization(client: @client, organization_guid: guid) end |