bitly 1.1.2 → 2.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +36 -3
- data/.rspec +3 -0
- data/.travis.yml +5 -2
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -2
- data/History.txt +18 -1
- data/LICENSE.md +1 -1
- data/README.md +151 -58
- data/Rakefile +4 -9
- data/bin/console +14 -0
- data/bin/oauth +10 -0
- data/bin/setup +8 -0
- data/bitly.gemspec +24 -29
- data/config/env.yml.example +5 -0
- data/docs/authentication.md +51 -0
- data/docs/bitlinks.md +2 -0
- data/docs/branded_short_domains.md +20 -0
- data/docs/groups.md +80 -0
- data/docs/oauth_apps.md +20 -0
- data/docs/organizations.md +74 -0
- data/docs/premium_apis.md +0 -0
- data/docs/users.md +1 -0
- data/lib/bitly.rb +6 -7
- data/lib/bitly/api.rb +16 -0
- data/lib/bitly/api/base.rb +22 -0
- data/lib/bitly/api/bitlink.rb +341 -0
- data/lib/bitly/api/bitlink/clicks_summary.rb +35 -0
- data/lib/bitly/api/bitlink/deeplink.rb +29 -0
- data/lib/bitly/api/bitlink/link_click.rb +74 -0
- data/lib/bitly/api/bitlink/paginated_list.rb +51 -0
- data/lib/bitly/api/bsd.rb +24 -0
- data/lib/bitly/api/click_metric.rb +185 -0
- data/lib/bitly/api/client.rb +588 -0
- data/lib/bitly/api/group.rb +232 -0
- data/lib/bitly/api/group/preferences.rb +73 -0
- data/lib/bitly/api/list.rb +22 -0
- data/lib/bitly/api/oauth_app.rb +26 -0
- data/lib/bitly/api/organization.rb +104 -0
- data/lib/bitly/api/shorten_counts.rb +61 -0
- data/lib/bitly/api/user.rb +107 -0
- data/lib/bitly/error.rb +33 -0
- data/lib/bitly/http.rb +6 -0
- data/lib/bitly/http/adapters/net_http.rb +27 -0
- data/lib/bitly/http/client.rb +33 -0
- data/lib/bitly/http/request.rb +116 -0
- data/lib/bitly/http/response.rb +65 -0
- data/lib/bitly/oauth.rb +109 -0
- data/lib/bitly/version.rb +3 -1
- metadata +88 -108
- data/Manifest +0 -37
- data/lib/bitly/url.rb +0 -103
- data/lib/bitly/utils.rb +0 -57
- data/lib/bitly/v3.rb +0 -14
- data/lib/bitly/v3/bitly.rb +0 -7
- data/lib/bitly/v3/country.rb +0 -13
- data/lib/bitly/v3/day.rb +0 -13
- data/lib/bitly/v3/missing_url.rb +0 -15
- data/lib/bitly/v3/oauth.rb +0 -41
- data/lib/bitly/v3/realtime_link.rb +0 -18
- data/lib/bitly/v3/referrer.rb +0 -13
- data/lib/bitly/v3/url.rb +0 -154
- data/test/bitly/test_client.rb +0 -266
- data/test/bitly/test_config.rb +0 -28
- data/test/bitly/test_url.rb +0 -167
- data/test/bitly/test_utils.rb +0 -79
- data/test/fixtures/cnn.json +0 -1
- data/test/fixtures/cnn_and_google.json +0 -1
- data/test/fixtures/expand_cnn.json +0 -1
- data/test/fixtures/expand_cnn_and_google.json +0 -1
- data/test/fixtures/google_and_cnn_info.json +0 -1
- data/test/fixtures/google_info.json +0 -1
- data/test/fixtures/google_stats.json +0 -1
- data/test/fixtures/shorten_error.json +0 -1
- data/test/test_helper.rb +0 -39
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "../base"
|
3
|
+
|
4
|
+
module Bitly
|
5
|
+
module API
|
6
|
+
class Bitlink
|
7
|
+
class ClicksSummary
|
8
|
+
include Base
|
9
|
+
|
10
|
+
def self.fetch(client:, bitlink:, unit: nil, units: nil, unit_reference: nil, size: nil)
|
11
|
+
response = client.request(
|
12
|
+
path: "/bitlinks/#{bitlink}/clicks/summary",
|
13
|
+
params: {
|
14
|
+
"unit" => nil,
|
15
|
+
"units" => nil,
|
16
|
+
"unit_reference" => nil,
|
17
|
+
"size" => nil
|
18
|
+
}
|
19
|
+
)
|
20
|
+
new(data: response.body, response: response)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.attributes
|
24
|
+
[:units, :unit, :unit_reference, :total_clicks]
|
25
|
+
end
|
26
|
+
attr_reader(*attributes)
|
27
|
+
|
28
|
+
def initialize(data:, response: nil)
|
29
|
+
assign_attributes(data)
|
30
|
+
@response = response
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "../base"
|
3
|
+
|
4
|
+
module Bitly
|
5
|
+
module API
|
6
|
+
class Bitlink
|
7
|
+
class Deeplink
|
8
|
+
include Base
|
9
|
+
|
10
|
+
def self.attributes
|
11
|
+
[:app_uri_path, :install_type, :install_url, :app_id]
|
12
|
+
end
|
13
|
+
attr_reader(*attributes)
|
14
|
+
|
15
|
+
def initialize(data:)
|
16
|
+
assign_attributes(data)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json(opts=nil)
|
20
|
+
self.class.attributes.reduce({}) do |memo, key|
|
21
|
+
value = instance_variable_get("@#{key}")
|
22
|
+
memo[key] = value if value
|
23
|
+
memo
|
24
|
+
end.to_json(opts)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "../base"
|
3
|
+
require_relative '../list'
|
4
|
+
|
5
|
+
module Bitly
|
6
|
+
module API
|
7
|
+
class Bitlink
|
8
|
+
class LinkClick
|
9
|
+
include Base
|
10
|
+
|
11
|
+
class List < Bitly::API::List
|
12
|
+
attr_reader :units, :unit_reference, :unit
|
13
|
+
def initialize(items:, response:, units:, unit_reference:, unit:)
|
14
|
+
super(items: items, response: response)
|
15
|
+
@units = units
|
16
|
+
@unit_reference = Time.parse(unit_reference) if unit_reference
|
17
|
+
@unit = unit
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Get the clicks for a bitlink.
|
23
|
+
# [`GET /v4/bitlink/{bitlink}/clicks`](https://dev.bitly.com/v4/#operation/getClicksForBitlink)
|
24
|
+
#
|
25
|
+
# @param client [Bitly::API::Client] An authorized API client
|
26
|
+
# @param bitlink [String] The Bitlink for which you want the clicks
|
27
|
+
# @param sort [String] The data to sort on. Default and only option is
|
28
|
+
# "clicks".
|
29
|
+
# @param unit [String] A unit of time. Default is "day" and can be
|
30
|
+
# "minute", "hour", "day", "week" or "month"
|
31
|
+
# @param units [Integer] An integer representing the time units to query
|
32
|
+
# data for. pass -1 to return all units of time. Defaults to -1.
|
33
|
+
# @param unit_reference [String] An ISO-8601 timestamp, indicating the
|
34
|
+
# most recent time for which to pull metrics. Will default to current
|
35
|
+
# time.
|
36
|
+
# @param size [Integer] The number of links to be returned. Defaults to 50
|
37
|
+
#
|
38
|
+
# @return [Bitly::API::Bitlink::LinkClick::List]
|
39
|
+
def self.list(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
|
40
|
+
response = client.request(
|
41
|
+
path: "/bitlinks/#{bitlink}/clicks",
|
42
|
+
params: {
|
43
|
+
"unit" => unit,
|
44
|
+
"units" => units,
|
45
|
+
"unit_reference" => unit_reference,
|
46
|
+
"size" => size
|
47
|
+
}
|
48
|
+
)
|
49
|
+
body = response.body
|
50
|
+
items = body["link_clicks"].map { |link_click| new(data: link_click) }
|
51
|
+
Bitly::API::Bitlink::LinkClick::List.new(
|
52
|
+
items: items,
|
53
|
+
response: response,
|
54
|
+
unit: body["unit"],
|
55
|
+
units: body["units"],
|
56
|
+
unit_reference: body["unit_reference"]
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.attributes
|
61
|
+
[:clicks]
|
62
|
+
end
|
63
|
+
def self.time_attributes
|
64
|
+
[:date]
|
65
|
+
end
|
66
|
+
attr_reader(*(attributes + time_attributes))
|
67
|
+
|
68
|
+
def initialize(data:)
|
69
|
+
assign_attributes(data)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Bitly
|
5
|
+
module API
|
6
|
+
class Bitlink
|
7
|
+
class PaginatedList < Bitly::API::List
|
8
|
+
attr_reader :next_url, :prev_url, :size, :page, :total
|
9
|
+
|
10
|
+
def initialize(items:, response: , client:)
|
11
|
+
super(items: items, response: response)
|
12
|
+
@client = client
|
13
|
+
if response.body["pagination"]
|
14
|
+
pagination = response.body["pagination"]
|
15
|
+
@next_url = pagination["next"]
|
16
|
+
@prev_url = pagination["prev"]
|
17
|
+
@size = pagination["size"]
|
18
|
+
@page = pagination["page"]
|
19
|
+
@total = pagination["total"]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def has_next_page?
|
24
|
+
!next_url.nil? && !next_url.empty?
|
25
|
+
end
|
26
|
+
|
27
|
+
def has_prev_page?
|
28
|
+
!prev_url.nil? && !prev_url.empty?
|
29
|
+
end
|
30
|
+
|
31
|
+
def next_page
|
32
|
+
has_next_page? ? get_page(uri: URI(next_url)) : nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def prev_page
|
36
|
+
has_prev_page? ? get_page(uri: URI(prev_url)) : nil
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def get_page(uri:)
|
42
|
+
response = @client.request(path: uri.path.gsub(/\/v4/, ""), params: CGI.parse(uri.query))
|
43
|
+
bitlinks = response.body["links"].map do |link|
|
44
|
+
Bitlink.new(data: link, client: @client)
|
45
|
+
end
|
46
|
+
self.class.new(items: bitlinks, response: response, client: @client)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "./list"
|
3
|
+
|
4
|
+
module Bitly
|
5
|
+
module API
|
6
|
+
module BSD
|
7
|
+
class List < Bitly::API::List ; end
|
8
|
+
|
9
|
+
##
|
10
|
+
# Fetch Branded Short Domains (BSDs).
|
11
|
+
# [`GET /v4/bsds`](https://dev.bitly.com/v4/#operation/getBSDs)
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# bsds = Bitly::API::BSD.list(client: client)
|
15
|
+
#
|
16
|
+
# @return [Array<String>]
|
17
|
+
def self.list(client:)
|
18
|
+
response = client.request(path: "/bsds")
|
19
|
+
bsds = response.body["bsds"]
|
20
|
+
List.new(items: bsds, response: response)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "./base"
|
3
|
+
require_relative './list'
|
4
|
+
|
5
|
+
module Bitly
|
6
|
+
module API
|
7
|
+
class ClickMetric
|
8
|
+
include Base
|
9
|
+
|
10
|
+
class List < Bitly::API::List
|
11
|
+
attr_reader :units, :unit_reference, :unit, :facet
|
12
|
+
def initialize(items:, response:, units:, unit_reference:, unit:, facet:)
|
13
|
+
super(items: items, response: response)
|
14
|
+
@units = units
|
15
|
+
# It looks like the API for referrers_by_domain returns the
|
16
|
+
# unit_reference in seconds, not a string, like every other endpoint.
|
17
|
+
begin
|
18
|
+
@unit_reference = Time.parse(unit_reference) if unit_reference
|
19
|
+
rescue TypeError
|
20
|
+
@unit_reference = Time.at(unit_reference)
|
21
|
+
end
|
22
|
+
@unit = unit
|
23
|
+
@facet = facet
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Referrers < Bitly::API::List
|
28
|
+
attr_reader :network
|
29
|
+
def initialize(items:, response:, network:)
|
30
|
+
super(items: items, response: response)
|
31
|
+
@network = network
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Gets the referring networks for the group.
|
37
|
+
# [`GET /v4/groups/{group_guid}/referring_networks`](https://dev.bitly.com/v4/#operation/GetGroupMetricsByReferringNetworks)
|
38
|
+
#
|
39
|
+
# @param client [Bitly::API::Client] An authorized API client
|
40
|
+
# @param group_guid [String] The guid of the group
|
41
|
+
# @param unit [String] A unit of time. Default is "day" and can be
|
42
|
+
# "minute", "hour", "day", "week" or "month"
|
43
|
+
# @param units [Integer] An integer representing the time units to query
|
44
|
+
# data for. pass -1 to return all units of time. Defaults to -1.
|
45
|
+
# @param unit_reference [String] An ISO-8601 timestamp, indicating the
|
46
|
+
# most recent time for which to pull metrics. Will default to current
|
47
|
+
# time.
|
48
|
+
# @param size [Integer] The number of links to be returned. Defaults to 50
|
49
|
+
#
|
50
|
+
# @return [Bitly::API::ClickMetric::List]
|
51
|
+
def self.list_referring_networks(client:, group_guid:, unit: nil, units: nil, size: nil, unit_reference: nil)
|
52
|
+
list_metrics(
|
53
|
+
client: client,
|
54
|
+
path: "/groups/#{group_guid}/referring_networks",
|
55
|
+
unit: unit,
|
56
|
+
units: units,
|
57
|
+
unit_reference: unit_reference,
|
58
|
+
size: size
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Gets the country click metrics for the group.
|
64
|
+
# [`GET /v4/groups/{group_guid}/countries`](https://dev.bitly.com/v4/#operation/getGroupMetricsByCountries)
|
65
|
+
#
|
66
|
+
# @param client [Bitly::API::Client] An authorized API client
|
67
|
+
# @param group_guid [String] The guid of the group
|
68
|
+
# @param unit [String] A unit of time. Default is "day" and can be
|
69
|
+
# "minute", "hour", "day", "week" or "month"
|
70
|
+
# @param units [Integer] An integer representing the time units to query
|
71
|
+
# data for. pass -1 to return all units of time. Defaults to -1.
|
72
|
+
# @param unit_reference [String] An ISO-8601 timestamp, indicating the
|
73
|
+
# most recent time for which to pull metrics. Will default to current
|
74
|
+
# time.
|
75
|
+
# @param size [Integer] The number of links to be returned. Defaults to 50
|
76
|
+
#
|
77
|
+
# @return [Bitly::API::ClickMetric::List]
|
78
|
+
def self.list_countries_by_group(client:, group_guid:, unit: nil, units: nil, size: nil, unit_reference: nil)
|
79
|
+
list_metrics(
|
80
|
+
client: client,
|
81
|
+
path: "/groups/#{group_guid}/countries",
|
82
|
+
unit: unit,
|
83
|
+
units: units,
|
84
|
+
unit_reference: unit_reference,
|
85
|
+
size: size
|
86
|
+
)
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.list_referrers(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
|
90
|
+
list_metrics(
|
91
|
+
client: client,
|
92
|
+
path: "/bitlinks/#{bitlink}/referrers",
|
93
|
+
unit: unit,
|
94
|
+
units: units,
|
95
|
+
unit_reference: unit_reference,
|
96
|
+
size: size
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.list_countries_by_bitlink(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
|
101
|
+
list_metrics(
|
102
|
+
client: client,
|
103
|
+
path: "/bitlinks/#{bitlink}/countries",
|
104
|
+
unit: unit,
|
105
|
+
units: units,
|
106
|
+
unit_reference: unit_reference,
|
107
|
+
size: size
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.list_referring_domains(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
|
112
|
+
list_metrics(
|
113
|
+
client: client,
|
114
|
+
path: "/bitlinks/#{bitlink}/referring_domains",
|
115
|
+
unit: unit,
|
116
|
+
units: units,
|
117
|
+
unit_reference: unit_reference,
|
118
|
+
size: size
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.list_referrers_by_domain(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
|
123
|
+
response = client.request(
|
124
|
+
path: "/bitlinks/#{bitlink}/referrers_by_domains",
|
125
|
+
params: {
|
126
|
+
"unit" => unit,
|
127
|
+
"units" => units,
|
128
|
+
"unit_reference" => unit_reference,
|
129
|
+
"size" => size
|
130
|
+
}
|
131
|
+
)
|
132
|
+
body = response.body
|
133
|
+
referrers = body["referrers_by_domain"].map do |referrer|
|
134
|
+
click_metrics = referrer["referrers"].map do |metric|
|
135
|
+
ClickMetric.new(data: metric)
|
136
|
+
end
|
137
|
+
Referrers.new(items: click_metrics, response: response, network: referrer["network"])
|
138
|
+
end
|
139
|
+
List.new(
|
140
|
+
items: referrers,
|
141
|
+
response: response,
|
142
|
+
unit: body["unit"],
|
143
|
+
units: body["units"],
|
144
|
+
unit_reference: body["unit_reference"],
|
145
|
+
facet: body["facet"]
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.attributes
|
150
|
+
[:clicks, :value]
|
151
|
+
end
|
152
|
+
attr_reader(*attributes)
|
153
|
+
|
154
|
+
def initialize(data:)
|
155
|
+
assign_attributes(data)
|
156
|
+
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
def self.list_metrics(client:, path:, unit:, units:, size:, unit_reference:)
|
161
|
+
response = client.request(
|
162
|
+
path: path,
|
163
|
+
params: {
|
164
|
+
"unit" => unit,
|
165
|
+
"units" => units,
|
166
|
+
"unit_reference" => unit_reference,
|
167
|
+
"size" => size
|
168
|
+
}
|
169
|
+
)
|
170
|
+
body = response.body
|
171
|
+
click_metrics = body["metrics"].map do |metric|
|
172
|
+
ClickMetric.new(data: metric)
|
173
|
+
end
|
174
|
+
List.new(
|
175
|
+
items: click_metrics,
|
176
|
+
response: response,
|
177
|
+
unit: body["unit"],
|
178
|
+
units: body["units"],
|
179
|
+
unit_reference: body["unit_reference"],
|
180
|
+
facet: body["facet"]
|
181
|
+
)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,588 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bitly
|
4
|
+
module API
|
5
|
+
##
|
6
|
+
# The class that all the API requests are made through. The
|
7
|
+
# Bitly::API::Client is authorized with an OAuth token and takes care of
|
8
|
+
# setting the correct path, parameters and headers when making requests to
|
9
|
+
# the API.
|
10
|
+
#
|
11
|
+
# This class will be used the most and includes short cut methods to request
|
12
|
+
# the popular objects in the system.
|
13
|
+
class Client
|
14
|
+
USER_AGENT = "Ruby Bitly/#{Bitly::VERSION}"
|
15
|
+
|
16
|
+
##
|
17
|
+
# Creates a new Bitly::API::Client, authorized with an OAuth token and
|
18
|
+
# with an optional HTTP client.
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# client = Bitly::API::Client.new(token: oauth_token)
|
22
|
+
#
|
23
|
+
# @param http [Bitly::HTTP::Client] An HTTP client, you can pass your own
|
24
|
+
# if you have a custom client you would like to use. Custom clients
|
25
|
+
# must have a request method that takes a Bitly::HTTP::Request object
|
26
|
+
# as a single parameter and returns a Bitly::HTTP::Response object (or
|
27
|
+
# an object that behaves like one).
|
28
|
+
# @param token [String] An OAuth token for a user authorized with the API.
|
29
|
+
#
|
30
|
+
# @return [Bitly::API::Client]
|
31
|
+
def initialize(http: Bitly::HTTP::Client.new, token:)
|
32
|
+
@http = http
|
33
|
+
@token = token
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Makes a request to the API by building up a Bitly::HTTP::Request and
|
38
|
+
# using the HTTP client to make that request and return a
|
39
|
+
# Bitly::HTTP::Response.
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# client.request("/shorten", method: "POST", params: { long_url => "https://example.com" })
|
43
|
+
#
|
44
|
+
# @param path [String] The resource path
|
45
|
+
# @param method [String] The HTTP method to use to request the path
|
46
|
+
# @param params [Hash<String, String>] The parameters to pass to the API
|
47
|
+
# @param headers [Hash<String, String>] Custom headers for the request
|
48
|
+
#
|
49
|
+
# @return [Bitly::HTTP::Response]
|
50
|
+
def request(path:, method: 'GET', params: {}, headers: {})
|
51
|
+
params = params.select { |k,v| !v.nil? }
|
52
|
+
headers = default_headers.merge(headers)
|
53
|
+
uri = Bitly::API::BASE_URL.dup
|
54
|
+
uri.path += path
|
55
|
+
request = Bitly::HTTP::Request.new(uri: uri, method: method, params: params, headers: headers)
|
56
|
+
@http.request(request)
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# Shortens a long URL.
|
61
|
+
# [`POST /v4/shorten`](https://dev.bitly.com/v4/#operation/createBitlink)
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# client.shorten(long_url: "http://example.com")
|
65
|
+
#
|
66
|
+
# @param long_url [String] The URL you want to shorten
|
67
|
+
# @param domain [String] The domain you want to shorten the URL with.
|
68
|
+
# "bit.ly" by default.
|
69
|
+
# @param group_guid [String] The group you want shorten this URL under
|
70
|
+
#
|
71
|
+
# @return [Bitly::API::Bitlink]
|
72
|
+
def shorten(long_url:, domain: nil, group_guid: nil)
|
73
|
+
Bitlink.shorten(client: self, long_url: long_url, domain: domain, group_guid: group_guid)
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# Creates a Bitlink with more options than #shorten.
|
78
|
+
# [`POST /v4/bitlinks`](https://dev.bitly.com/v4/#operation/createFullBitlink)
|
79
|
+
#
|
80
|
+
# @example
|
81
|
+
# bitlink = client.create_bitlink(long_url: "http://example.com", title: "An example")
|
82
|
+
#
|
83
|
+
# @param long_url [String] A long URL that you want shortened
|
84
|
+
# @param domain [String] The bitly domain you want to shorten, API default
|
85
|
+
# is "bit.ly"
|
86
|
+
# @param group_guid [String] The GUID of the group for which you want to
|
87
|
+
# shorten this URL
|
88
|
+
# @param title [String] A descriptive title for the link
|
89
|
+
# @param tags [Array<String>] Some tags for the Bitlink
|
90
|
+
# @param deeplinks [Array<Bitly::API::Bitlink::Deeplink>]
|
91
|
+
#
|
92
|
+
# @return [Bitly::API::Bitlink]
|
93
|
+
def create_bitlink(long_url:, domain: nil, group_guid: nil, title: nil, tags: nil, deeplinks: nil)
|
94
|
+
Bitlink.create(client: self, long_url: long_url, domain: domain, group_guid: group_guid, title: title, tags: tags, deeplinks: deeplinks)
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# Return information about a bitlink
|
99
|
+
# [`GET /v4/bitlink/{bitlink}`](https://dev.bitly.com/v4/#operation/getBitlink)
|
100
|
+
#
|
101
|
+
# @example
|
102
|
+
# bitlink = client.bitlink(bitlink: "bit.ly/example")
|
103
|
+
#
|
104
|
+
# @param bitlink [String] The bitlink you want information about
|
105
|
+
#
|
106
|
+
# @return [Bitly::API::Bitlink]
|
107
|
+
def bitlink(bitlink:)
|
108
|
+
Bitlink.fetch(client: self, bitlink: bitlink)
|
109
|
+
end
|
110
|
+
|
111
|
+
##
|
112
|
+
# Return public information about a bitlink.
|
113
|
+
# [`POST /v4/expand`](https://dev.bitly.com/v4/#operation/expandBitlink)
|
114
|
+
#
|
115
|
+
# @example
|
116
|
+
# bitlink = client.expand(bitlink: "bit.ly/example")
|
117
|
+
#
|
118
|
+
# @param bitlink [String] The bitlink you want information about
|
119
|
+
#
|
120
|
+
# @return [Bitly::API::Bitlink]
|
121
|
+
def expand(bitlink:)
|
122
|
+
Bitlink.expand(client: self, bitlink: bitlink)
|
123
|
+
end
|
124
|
+
|
125
|
+
##
|
126
|
+
# Returns a list of Bitlinks sorted by clicks.
|
127
|
+
# [`GET /v4/groups/{group_guid}/bitlinks/{sort}`](https://dev.bitly.com/v4/#operation/getSortedBitlinks)
|
128
|
+
#
|
129
|
+
# The API returns a separate list of the links and the click counts, but
|
130
|
+
# this method assigns the number of clicks for each link to the Bitlink
|
131
|
+
# object and sorts the resulting list in descending order.
|
132
|
+
#
|
133
|
+
# Sorted lists are not paginated, so do not have any pagination detail.
|
134
|
+
#
|
135
|
+
# @example
|
136
|
+
# links = client.sorted_list(group_guid: guid)
|
137
|
+
#
|
138
|
+
# @param group_guid [String] The group for which you want to return links
|
139
|
+
# @param sort [String] The data to sort on. Default and only option is
|
140
|
+
# "clicks".
|
141
|
+
# @param unit [String] A unit of time. Default is "day" and can be
|
142
|
+
# "minute", "hour", "day", "week" or "month"
|
143
|
+
# @param units [Integer] An integer representing the time units to query
|
144
|
+
# data for. pass -1 to return all units of time. Defaults to -1.
|
145
|
+
# @param unit_reference [String] An ISO-8601 timestamp, indicating the
|
146
|
+
# most recent time for which to pull metrics. Will default to current
|
147
|
+
# time.
|
148
|
+
# @param size [Integer] The number of links to be returned. Defaults to 50
|
149
|
+
#
|
150
|
+
# @returns [Bitly::API::Bitlink::List]
|
151
|
+
def sorted_bitlinks(
|
152
|
+
group_guid:,
|
153
|
+
sort: "clicks",
|
154
|
+
unit: nil,
|
155
|
+
units: nil,
|
156
|
+
unit_reference: nil,
|
157
|
+
size: nil
|
158
|
+
)
|
159
|
+
Bitlink.sorted_list(
|
160
|
+
client: self,
|
161
|
+
group_guid: group_guid,
|
162
|
+
sort: sort,
|
163
|
+
unit: unit,
|
164
|
+
units: units,
|
165
|
+
unit_reference: unit_reference,
|
166
|
+
size: size
|
167
|
+
)
|
168
|
+
end
|
169
|
+
|
170
|
+
##
|
171
|
+
# Update a Bitlink.
|
172
|
+
# [`PATCH /v4/bitlink/{bitlink}`](https://dev.bitly.com/v4/#operation/updateBitlink)
|
173
|
+
#
|
174
|
+
# The parameters listed below are from the documentation. Some only work
|
175
|
+
# if you have a Bitly Pro account.
|
176
|
+
#
|
177
|
+
# @example
|
178
|
+
# client.update_bitlink(title: "New title")
|
179
|
+
#
|
180
|
+
# @param archived [Boolean]
|
181
|
+
# @param tags [Array<String>]
|
182
|
+
# @param created_at [String]
|
183
|
+
# @param title [String]
|
184
|
+
# @param deeplinks [Array<Bitly::API::Bitlink::Deeplink>]
|
185
|
+
# @param created_by [String]
|
186
|
+
# @param long_url [String]
|
187
|
+
# @param client_id [String]
|
188
|
+
# @param custom_bitlinks [Array<String>]
|
189
|
+
# @param link [String]
|
190
|
+
# @param id [String]
|
191
|
+
# @param references [Hash<String, String>]
|
192
|
+
#
|
193
|
+
# @returns [Bitly::API::Bitlink]
|
194
|
+
def update_bitlink(
|
195
|
+
bitlink:,
|
196
|
+
archived: nil,
|
197
|
+
tags: nil,
|
198
|
+
created_at: nil,
|
199
|
+
title: nil,
|
200
|
+
deeplinks: nil,
|
201
|
+
created_by: nil,
|
202
|
+
long_url: nil,
|
203
|
+
client_id: nil,
|
204
|
+
custom_bitlinks: nil,
|
205
|
+
link: nil,
|
206
|
+
id: nil,
|
207
|
+
references: nil
|
208
|
+
)
|
209
|
+
bitlink = Bitlink.new(data: { "id" => bitlink }, client: self)
|
210
|
+
bitlink.update(
|
211
|
+
archived: archived,
|
212
|
+
tags: tags,
|
213
|
+
created_at: created_at,
|
214
|
+
title: title,
|
215
|
+
deeplinks: deeplinks,
|
216
|
+
created_by: created_by,
|
217
|
+
long_url: long_url,
|
218
|
+
client_id: client_id,
|
219
|
+
custom_bitlinks: custom_bitlinks,
|
220
|
+
link: link,
|
221
|
+
id: id,
|
222
|
+
references: references
|
223
|
+
)
|
224
|
+
end
|
225
|
+
|
226
|
+
##
|
227
|
+
# Get the clicks for a bitlink.
|
228
|
+
# [`GET /v4/bitlink/{bitlink}/clicks`](https://dev.bitly.com/v4/#operation/getClicksForBitlink)
|
229
|
+
#
|
230
|
+
# @param bitlink [String] The Bitlink for which you want the clicks
|
231
|
+
# @param sort [String] The data to sort on. Default and only option is
|
232
|
+
# "clicks".
|
233
|
+
# @param unit [String] A unit of time. Default is "day" and can be
|
234
|
+
# "minute", "hour", "day", "week" or "month"
|
235
|
+
# @param units [Integer] An integer representing the time units to query
|
236
|
+
# data for. pass -1 to return all units of time. Defaults to -1.
|
237
|
+
# @param unit_reference [String] An ISO-8601 timestamp, indicating the
|
238
|
+
# most recent time for which to pull metrics. Will default to current
|
239
|
+
# time.
|
240
|
+
# @param size [Integer] The number of links to be returned. Defaults to 50
|
241
|
+
#
|
242
|
+
# @return [Bitly::API::Bitlink::LinkClick::List]
|
243
|
+
def bitlink_clicks(bitlink:, unit: nil, units: nil, unit_reference: nil, size: nil)
|
244
|
+
Bitlink::LinkClick.list(
|
245
|
+
client: self,
|
246
|
+
bitlink: bitlink,
|
247
|
+
unit: unit,
|
248
|
+
units: units,
|
249
|
+
unit_reference: unit_reference,
|
250
|
+
size: size
|
251
|
+
)
|
252
|
+
end
|
253
|
+
|
254
|
+
##
|
255
|
+
# Get a list of organizations from the API.
|
256
|
+
# [`GET /v4/organizations`](https://dev.bitly.com/v4/#operation/getOrganizations)
|
257
|
+
#
|
258
|
+
# @example
|
259
|
+
# organizations = client.organizations
|
260
|
+
#
|
261
|
+
# @return [Bitly::API::Organization::List]
|
262
|
+
def organizations
|
263
|
+
Organization.list(client: self)
|
264
|
+
end
|
265
|
+
|
266
|
+
##
|
267
|
+
# Retrieve an organization from the API.
|
268
|
+
# [`GET /v4/organizations/{organization_guid}`](https://dev.bitly.com/v4/#operation/getOrganization)
|
269
|
+
#
|
270
|
+
# @example
|
271
|
+
# organization = client.organization(organization_guid: guid)
|
272
|
+
#
|
273
|
+
# @param organization_guid [String] An organization guid
|
274
|
+
#
|
275
|
+
# @return [Bitly::API::Organization]
|
276
|
+
def organization(organization_guid:)
|
277
|
+
Organization.fetch(client: self, organization_guid: organization_guid)
|
278
|
+
end
|
279
|
+
|
280
|
+
##
|
281
|
+
# Shorten counts by organization
|
282
|
+
# [`GET /v4/organizations/{organization_guid}/shorten_counts`](https://dev.bitly.com/v4/#operation/getOrganizationShortenCounts)
|
283
|
+
#
|
284
|
+
# @example
|
285
|
+
# shorten_counts = client.organization_shorten_counts(organization_guid: organization_guid)
|
286
|
+
#
|
287
|
+
# @param organization_guid [String] The guid of the organization for which
|
288
|
+
# you want shorten counts
|
289
|
+
#
|
290
|
+
# @return [Bitly::API::ShortenCounts]
|
291
|
+
def organization_shorten_counts(organization_guid:)
|
292
|
+
Bitly::API::ShortenCounts.by_organization(client: self, organization_guid: organization_guid)
|
293
|
+
end
|
294
|
+
|
295
|
+
##
|
296
|
+
# Gets the authorized user from the API.
|
297
|
+
# [`GET /v4/user`](https://dev.bitly.com/v4/#operation/getUser)
|
298
|
+
#
|
299
|
+
# @example
|
300
|
+
# user = client.user
|
301
|
+
#
|
302
|
+
# @return [Bitly::API::User]
|
303
|
+
def user
|
304
|
+
User.fetch(client: self)
|
305
|
+
end
|
306
|
+
|
307
|
+
##
|
308
|
+
# Allows you to update the authorized user's name or default group guid.
|
309
|
+
# [`PATCH /v4/user`](https://dev.bitly.com/v4/#operation/updateUser)]
|
310
|
+
#
|
311
|
+
# @example
|
312
|
+
# client.update_user(name: "New Name", default_group_guid: "aaabbb")
|
313
|
+
#
|
314
|
+
# @param name [String] A new name
|
315
|
+
# @param default_group_guid [String] A new default guid
|
316
|
+
#
|
317
|
+
# @return [Bitly::API::User]
|
318
|
+
def update_user(name: nil, default_group_guid: nil)
|
319
|
+
user = Bitly::API::User.new(client: self, data: {})
|
320
|
+
user.update(name: name, default_group_guid: default_group_guid)
|
321
|
+
end
|
322
|
+
|
323
|
+
##
|
324
|
+
# Lists groups the authorized user can see.
|
325
|
+
# [`GET /v4/groups`](https://dev.bitly.com/v4/#operation/getGroups)
|
326
|
+
#
|
327
|
+
# @example
|
328
|
+
# groups = client.groups
|
329
|
+
#
|
330
|
+
# @param organization [String] The organization guid of the organization
|
331
|
+
# for which you want the available groups.
|
332
|
+
#
|
333
|
+
# @return [Bitly::API::Group::List]
|
334
|
+
def groups(organization_guid: nil)
|
335
|
+
Group.list(client: self, organization_guid: organization_guid)
|
336
|
+
end
|
337
|
+
|
338
|
+
##
|
339
|
+
# Fetch a particular group.
|
340
|
+
# [`GET /v4/groups/{group_guid}`](https://dev.bitly.com/v4/#operation/getGroup)
|
341
|
+
#
|
342
|
+
# @example
|
343
|
+
# group = client.group(guid)
|
344
|
+
#
|
345
|
+
# @param guid [String] The guid of the group you want.
|
346
|
+
#
|
347
|
+
# @return [Bitly::API::Group]
|
348
|
+
def group(group_guid:)
|
349
|
+
Group.fetch(client: self, group_guid: group_guid)
|
350
|
+
end
|
351
|
+
|
352
|
+
##
|
353
|
+
# Fetch the shorten counts for a group.
|
354
|
+
# [`GET /v4/groups/{group_guid}/shorten_counts`](https://dev.bitly.com/v4/#operation/getGroupShortenCounts)
|
355
|
+
#
|
356
|
+
# @example
|
357
|
+
# shorten_counts = client.group_shorten_counts(guid: group_guid)
|
358
|
+
#
|
359
|
+
# @param guid [String] The guid of the group for which you want the
|
360
|
+
# shorten counts.
|
361
|
+
#
|
362
|
+
# @return [Bitly::API::ShortenCounts]
|
363
|
+
def group_shorten_counts(group_guid:)
|
364
|
+
Bitly::API::ShortenCounts.by_group(client: self, group_guid: group_guid)
|
365
|
+
end
|
366
|
+
|
367
|
+
##
|
368
|
+
# Fetch a group's preferences.
|
369
|
+
# [`GET /v4/groups/{group_guid}/preferences`](https://dev.bitly.com/v4/#operation/getGroupPreferences)
|
370
|
+
#
|
371
|
+
# @param group_guid [String] The group's guid
|
372
|
+
#
|
373
|
+
# @return [Bitly::API::Group::Preferences]
|
374
|
+
def group_preferences(group_guid:)
|
375
|
+
Group::Preferences.fetch(client: self, group_guid: group_guid)
|
376
|
+
end
|
377
|
+
|
378
|
+
##
|
379
|
+
# Update a group's preferences.
|
380
|
+
# [`PATCH /v4/groups/{group_guid}/preferences`](https://dev.bitly.com/v4/#operation/updateGroupPreferences)
|
381
|
+
#
|
382
|
+
# @param group_guid [String] The group's guid
|
383
|
+
# @param domain_preference [String] The new domain preference for this
|
384
|
+
# group
|
385
|
+
#
|
386
|
+
# @return [Bitly::API::Group::Preferences]
|
387
|
+
def update_group_preferences(group_guid:, domain_preference:)
|
388
|
+
group_preferences = Group::Preferences.new(data: { "group_guid" => group_guid }, client: self)
|
389
|
+
group_preferences.update(domain_preference: domain_preference)
|
390
|
+
end
|
391
|
+
|
392
|
+
##
|
393
|
+
# Allows you to update a group's name, organization or BSDs.
|
394
|
+
# [`PATCH /v4/groups/{group_guid}`](https://dev.bitly.com/v4/#operation/updateGroup)
|
395
|
+
#
|
396
|
+
# @example
|
397
|
+
# client.update_group(group_guid: group_guid, name: "New Name", organization_guid: "aaabbb")
|
398
|
+
#
|
399
|
+
# @param group_guid [String] The group's guid
|
400
|
+
# @param name [String] A new name
|
401
|
+
# @param organization_guid [String] A new organization guid
|
402
|
+
# @param bsds [Array<String>] An array of branded short domains
|
403
|
+
#
|
404
|
+
# @return [Bitly::API::Group]
|
405
|
+
def update_group(group_guid:, name: nil, organization_guid: nil, bsds: nil)
|
406
|
+
group = Group.new(data: { "guid" => group_guid }, client: self)
|
407
|
+
group.update(
|
408
|
+
name: name,
|
409
|
+
organization_guid: organization_guid,
|
410
|
+
bsds: bsds
|
411
|
+
)
|
412
|
+
end
|
413
|
+
|
414
|
+
##
|
415
|
+
# Retrieve a list of bitlinks by group
|
416
|
+
# [`GET /v4/groups/{group_guid}/bitlinks`](https://dev.bitly.com/v4/#operation/getBitlinksByGroup)
|
417
|
+
#
|
418
|
+
# @example
|
419
|
+
# bitlinks = client.group_bitlinks(group_guid: guid)
|
420
|
+
#
|
421
|
+
# @param client [Bitly::API::Client] An authorized API client
|
422
|
+
# @param group_guid [String] The group guid for which you want bitlinks
|
423
|
+
# @param size [Integer] The number of Bitlinks to return, max 100
|
424
|
+
# @param page [Integer] The page of bitlinks to request
|
425
|
+
# @param keyword [String] Custom keyword to filter on history entries
|
426
|
+
# @param query [String] A value to search for Bitlinks
|
427
|
+
# @param created_before [Integer] Timestamp as an integer unix epoch
|
428
|
+
# @param created_after [Integer] Timestamp as an integer unix epoch
|
429
|
+
# @param modified_after [Integer] Timestamp as an integer unix epoch
|
430
|
+
# @param archived [String] Whether or not to include archived Bitlinks.
|
431
|
+
# One of "on", "off" or "both". Defaults to "off".
|
432
|
+
# @param deeplinks [String] Filter to only Bitlinks that contain
|
433
|
+
# deeplinks. One of "on", "off" or "both". Defaults to "both".
|
434
|
+
# @param domain_deeplinks [String] Filter to only Bitlinks that contain
|
435
|
+
# deeplinks configured with a custom domain. One of "on", "off" or
|
436
|
+
# "both". Defaults to "both".
|
437
|
+
# @param campaign_guid [String] Filter to return only links for the given
|
438
|
+
# campaign GUID, can be provided
|
439
|
+
# @param channel_guid [String] Filter to return only links for the given
|
440
|
+
# channel GUID, can be provided, overrides all other parameters
|
441
|
+
# @param custom_bitlink [String] Filter to return only custom Bitlinks.
|
442
|
+
# One of "on", "off" or "both". Defaults to "both".
|
443
|
+
# @param tags [Array<String>] Filter by the given tags.
|
444
|
+
# @param encoding_login [Array<String>] Filter by the login of the
|
445
|
+
# authenticated user that created the Bitlink.
|
446
|
+
#
|
447
|
+
# @return [Bitly::API::Bitlink::PaginatedList]
|
448
|
+
def group_bitlinks(
|
449
|
+
group_guid:,
|
450
|
+
size: nil,
|
451
|
+
page: nil,
|
452
|
+
keyword: nil,
|
453
|
+
query: nil,
|
454
|
+
created_before: nil,
|
455
|
+
created_after: nil,
|
456
|
+
modified_after: nil,
|
457
|
+
archived: nil,
|
458
|
+
deeplinks: nil,
|
459
|
+
domain_deeplinks: nil,
|
460
|
+
campaign_guid: nil,
|
461
|
+
channel_guid: nil,
|
462
|
+
custom_bitlink: nil,
|
463
|
+
tags: nil,
|
464
|
+
encoding_login: nil
|
465
|
+
)
|
466
|
+
Bitlink.list(
|
467
|
+
client: self,
|
468
|
+
group_guid: group_guid,
|
469
|
+
size: size,
|
470
|
+
page: page,
|
471
|
+
keyword: keyword,
|
472
|
+
query: query,
|
473
|
+
created_before: created_before,
|
474
|
+
created_after: created_after,
|
475
|
+
modified_after: modified_after,
|
476
|
+
archived: archived,
|
477
|
+
deeplinks: deeplinks,
|
478
|
+
domain_deeplinks: domain_deeplinks,
|
479
|
+
campaign_guid: campaign_guid,
|
480
|
+
channel_guid: channel_guid,
|
481
|
+
custom_bitlink: custom_bitlink,
|
482
|
+
tags: tags,
|
483
|
+
encoding_login: encoding_login
|
484
|
+
)
|
485
|
+
end
|
486
|
+
|
487
|
+
##
|
488
|
+
# Deletes a group.
|
489
|
+
# [`DELETE /v4/groups/{group_guid}`](https://dev.bitly.com/v4/#operation/deleteGroup)
|
490
|
+
#
|
491
|
+
# @example
|
492
|
+
# client.delete_group(group_guid: group_guid)
|
493
|
+
#
|
494
|
+
# @return [Nil]
|
495
|
+
def delete_group(group_guid:)
|
496
|
+
group = Group.new(data: { "guid" => group_guid }, client: self)
|
497
|
+
group.delete
|
498
|
+
end
|
499
|
+
|
500
|
+
##
|
501
|
+
# Gets the referring networks for the group.
|
502
|
+
# [`GET /v4/groups/{group_guid}/referring_networks`](https://dev.bitly.com/v4/#operation/GetGroupMetricsByReferringNetworks)
|
503
|
+
#
|
504
|
+
# @param group_guid [String] The guid of the group
|
505
|
+
# @param unit [String] A unit of time. Default is "day" and can be
|
506
|
+
# "minute", "hour", "day", "week" or "month"
|
507
|
+
# @param units [Integer] An integer representing the time units to query
|
508
|
+
# data for. pass -1 to return all units of time. Defaults to -1.
|
509
|
+
# @param unit_reference [String] An ISO-8601 timestamp, indicating the
|
510
|
+
# most recent time for which to pull metrics. Will default to current
|
511
|
+
# time.
|
512
|
+
# @param size [Integer] The number of links to be returned. Defaults to 50
|
513
|
+
#
|
514
|
+
# @return [Bitly::API::ClickMetric::List]
|
515
|
+
def group_referring_networks(group_guid:, unit: nil, units: nil, size: nil, unit_reference: nil)
|
516
|
+
ClickMetric.list_referring_networks(
|
517
|
+
client: self,
|
518
|
+
group_guid: group_guid,
|
519
|
+
unit: unit,
|
520
|
+
units: units,
|
521
|
+
unit_reference: unit_reference,
|
522
|
+
size: size
|
523
|
+
)
|
524
|
+
end
|
525
|
+
|
526
|
+
##
|
527
|
+
# Gets the country click metrics for the group.
|
528
|
+
# [`GET /v4/groups/{group_guid}/countries`](https://dev.bitly.com/v4/#operation/getGroupMetricsByCountries)
|
529
|
+
#
|
530
|
+
# @param group_guid [String] The guid of the group
|
531
|
+
# @param unit [String] A unit of time. Default is "day" and can be
|
532
|
+
# "minute", "hour", "day", "week" or "month"
|
533
|
+
# @param units [Integer] An integer representing the time units to query
|
534
|
+
# data for. pass -1 to return all units of time. Defaults to -1.
|
535
|
+
# @param unit_reference [String] An ISO-8601 timestamp, indicating the
|
536
|
+
# most recent time for which to pull metrics. Will default to current
|
537
|
+
# time.
|
538
|
+
# @param size [Integer] The number of links to be returned. Defaults to 50
|
539
|
+
#
|
540
|
+
# @return [Bitly::API::ClickMetric::List]
|
541
|
+
def group_countries(group_guid:, unit: nil, units: nil, size: nil, unit_reference: nil)
|
542
|
+
ClickMetric.list_countries_by_group(
|
543
|
+
client: self,
|
544
|
+
group_guid: group_guid,
|
545
|
+
unit: unit,
|
546
|
+
units: units,
|
547
|
+
unit_reference: unit_reference,
|
548
|
+
size: size
|
549
|
+
)
|
550
|
+
end
|
551
|
+
|
552
|
+
##
|
553
|
+
# Fetch Branded Short Domains (BSDs).
|
554
|
+
# [`GET /v4/bsds`](https://dev.bitly.com/v4/#operation/getBSDs)
|
555
|
+
#
|
556
|
+
# @example
|
557
|
+
# bsds = client.bsds
|
558
|
+
#
|
559
|
+
# @return [Array<String>]
|
560
|
+
def bsds
|
561
|
+
BSD.list(client: self)
|
562
|
+
end
|
563
|
+
|
564
|
+
##
|
565
|
+
# Fetch OAuth application by client ID
|
566
|
+
# [`GET /v4/apps/{client_id}`)](https://dev.bitly.com/v4/#operation/getOAuthApp)
|
567
|
+
#
|
568
|
+
# @example
|
569
|
+
# app = client.oauth_app(client_id: "client_id")
|
570
|
+
#
|
571
|
+
# @return Bitly::API::OAuthApp
|
572
|
+
def oauth_app(client_id:)
|
573
|
+
OAuthApp.fetch(client: self, client_id: client_id)
|
574
|
+
end
|
575
|
+
|
576
|
+
private
|
577
|
+
|
578
|
+
def default_headers
|
579
|
+
{
|
580
|
+
"User-Agent" => USER_AGENT,
|
581
|
+
"Authorization" => "Bearer #{@token}",
|
582
|
+
"Accept" => "application/json",
|
583
|
+
"Content-Type" => "application/json"
|
584
|
+
}
|
585
|
+
end
|
586
|
+
end
|
587
|
+
end
|
588
|
+
end
|