class Bitly::API::ShortenCounts

Constants

Metric

Attributes

metrics[R]

Public Class Methods

attributes() click to toggle source
# File lib/bitly/api/shorten_counts.rb, line 9
def self.attributes
  [:units, :facet, :unit_reference, :unit]
end
by_group(client:, group_guid:) click to toggle source

Shorten counts by group [`GET /v4/groups/{group_guid}/shorten_counts`](dev.bitly.com/v4/#operation/getGroupShortenCounts)

@example

shorten_counts = Bitly::API::ShortenCounts.by_group(client: client, group_guid: group_guid)

@param client [Bitly::API::Client] An authorized API client @param group_guid [String] The guid of the group for which you want

shorten counts

@return [Bitly::API::ShortenCounts]

# File lib/bitly/api/shorten_counts.rb, line 30
def self.by_group(client:, group_guid:)
  response = client.request(path: "/groups/#{group_guid}/shorten_counts")
  new(data: response.body, response: response)
end
by_organization(client:, organization_guid:) click to toggle source

Shorten counts by organization [`GET /v4/organizations/{organization_guid}/shorten_counts`](dev.bitly.com/v4/#operation/getOrganizationShortenCounts)

@example

shorten_counts = Bitly::API::ShortenCounts.by_organization(client: client, organization_guid: organization_guid)

@param client [Bitly::API::Client] An authorized API client @param organization_guid [String] The guid of the organization for which

you want shorten counts

@return [Bitly::API::ShortenCounts]

# File lib/bitly/api/shorten_counts.rb, line 47
def self.by_organization(client:, organization_guid:)
  response = client.request(path: "/organizations/#{organization_guid}/shorten_counts")
  new(data: response.body, response: response)
end
new(data:, response: nil) click to toggle source
# File lib/bitly/api/shorten_counts.rb, line 52
def initialize(data:, response: nil)
  assign_attributes(data)
  @metrics = data["metrics"].map do |metric|
    Metric.new(metric["key"], metric["value"])
  end
  @response = response
end