Class: Bitly::API::ShortenCounts

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/bitly/api/shorten_counts.rb

Defined Under Namespace

Classes: Metric

Instance Attribute Summary collapse

Attributes included from Base

#response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#assign_attributes

Constructor Details

#initialize(data:, response: nil) ⇒ ShortenCounts

Returns a new instance of ShortenCounts.



52
53
54
55
56
57
58
# 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

Instance Attribute Details

#metricsObject (readonly)

Returns the value of attribute metrics.



14
15
16
# File 'lib/bitly/api/shorten_counts.rb', line 14

def metrics
  @metrics
end

Class Method Details

.attributesObject



9
10
11
# File 'lib/bitly/api/shorten_counts.rb', line 9

def self.attributes
  [:units, :facet, :unit_reference, :unit]
end

.by_group(client:, group_guid:) ⇒ Bitly::API::ShortenCounts

Shorten counts by group [‘GET /v4/groups/group_guid/shorten_counts`](dev.bitly.com/api-reference/#getGroupShortenCounts)

Examples:

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

Parameters:

  • client (Bitly::API::Client)

    An authorized API client

  • group_guid (String)

    The guid of the group for which you want shorten counts

Returns:



30
31
32
33
# 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:) ⇒ Bitly::API::ShortenCounts

Shorten counts by organization [‘GET /v4/organizations/organization_guid/shorten_counts`](dev.bitly.com/api-reference/#getOrganizationShortenCounts)

Examples:

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

Parameters:

  • client (Bitly::API::Client)

    An authorized API client

  • organization_guid (String)

    The guid of the organization for which you want shorten counts

Returns:



47
48
49
50
# 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