bitly 1.1.1 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +36 -3
  3. data/.rspec +3 -0
  4. data/.travis.yml +6 -2
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +5 -2
  7. data/History.txt +32 -1
  8. data/LICENSE.md +1 -1
  9. data/README.md +151 -58
  10. data/Rakefile +6 -9
  11. data/bitly.gemspec +36 -32
  12. data/config/env.yml.example +5 -0
  13. data/lib/bitly.rb +9 -7
  14. data/lib/bitly/api.rb +19 -0
  15. data/lib/bitly/api/base.rb +23 -0
  16. data/lib/bitly/api/bitlink.rb +342 -0
  17. data/lib/bitly/api/bitlink/clicks_summary.rb +35 -0
  18. data/lib/bitly/api/bitlink/deeplink.rb +29 -0
  19. data/lib/bitly/api/bitlink/link_click.rb +75 -0
  20. data/lib/bitly/api/bitlink/paginated_list.rb +52 -0
  21. data/lib/bitly/api/bsd.rb +24 -0
  22. data/lib/bitly/api/click_metric.rb +186 -0
  23. data/lib/bitly/api/client.rb +588 -0
  24. data/lib/bitly/api/group.rb +232 -0
  25. data/lib/bitly/api/group/preferences.rb +73 -0
  26. data/lib/bitly/api/list.rb +22 -0
  27. data/lib/bitly/api/oauth_app.rb +26 -0
  28. data/lib/bitly/api/organization.rb +104 -0
  29. data/lib/bitly/api/shorten_counts.rb +61 -0
  30. data/lib/bitly/api/user.rb +107 -0
  31. data/lib/bitly/error.rb +33 -0
  32. data/lib/bitly/http.rb +10 -0
  33. data/lib/bitly/http/adapters.rb +9 -0
  34. data/lib/bitly/http/adapters/net_http.rb +27 -0
  35. data/lib/bitly/http/client.rb +33 -0
  36. data/lib/bitly/http/request.rb +118 -0
  37. data/lib/bitly/http/response.rb +66 -0
  38. data/lib/bitly/oauth.rb +109 -0
  39. data/lib/bitly/version.rb +3 -1
  40. metadata +82 -111
  41. data/Manifest +0 -37
  42. data/lib/bitly/client.rb +0 -145
  43. data/lib/bitly/config.rb +0 -29
  44. data/lib/bitly/url.rb +0 -103
  45. data/lib/bitly/utils.rb +0 -57
  46. data/lib/bitly/v3.rb +0 -14
  47. data/lib/bitly/v3/bitly.rb +0 -7
  48. data/lib/bitly/v3/client.rb +0 -207
  49. data/lib/bitly/v3/country.rb +0 -13
  50. data/lib/bitly/v3/day.rb +0 -13
  51. data/lib/bitly/v3/missing_url.rb +0 -15
  52. data/lib/bitly/v3/oauth.rb +0 -41
  53. data/lib/bitly/v3/realtime_link.rb +0 -18
  54. data/lib/bitly/v3/referrer.rb +0 -13
  55. data/lib/bitly/v3/url.rb +0 -154
  56. data/lib/bitly/v3/user.rb +0 -135
  57. data/test/bitly/test_client.rb +0 -266
  58. data/test/bitly/test_config.rb +0 -28
  59. data/test/bitly/test_url.rb +0 -167
  60. data/test/bitly/test_utils.rb +0 -79
  61. data/test/fixtures/cnn.json +0 -1
  62. data/test/fixtures/cnn_and_google.json +0 -1
  63. data/test/fixtures/expand_cnn.json +0 -1
  64. data/test/fixtures/expand_cnn_and_google.json +0 -1
  65. data/test/fixtures/google_and_cnn_info.json +0 -1
  66. data/test/fixtures/google_info.json +0 -1
  67. data/test/fixtures/google_stats.json +0 -1
  68. data/test/fixtures/shorten_error.json +0 -1
  69. data/test/test_helper.rb +0 -39
data/Rakefile CHANGED
@@ -1,11 +1,8 @@
1
- require 'bundler/gem_tasks'
1
+ # frozen_string_literal: true
2
2
 
3
- require 'rake/testtask'
4
- task :default => [:test]
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
5
 
6
- desc 'Run tests (default)'
7
- Rake::TestTask.new(:test) do |t|
8
- t.test_files = FileList['test/**/test_*.rb']
9
- t.ruby_opts = ['-Itest']
10
- t.ruby_opts << '-rubygems' if defined? Gem
11
- end
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -1,38 +1,42 @@
1
- # -*- encoding: utf-8 -*-
2
- # stub: bitly 1.1.0 ruby lib
1
+ # frozen_string_literal: true
2
+
3
3
  lib = File.expand_path("../lib", __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'bitly/version'
5
+ require "bitly/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = "bitly"
9
- spec.version = Bitly::VERSION
10
- spec.authors = ["Phil Nash"]
11
- spec.email = "philnash@gmail.com"
12
-
13
- spec.summary = "Use the bit.ly API to shorten or expand URLs"
14
- spec.description = "Use the bit.ly API to shorten or expand URLs"
15
- spec.homepage = "http://github.com/philnash/bitly"
16
- spec.license = "MIT"
17
-
18
- spec.files = `git ls-files -z`.split("\x0")
19
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
- spec.require_paths = ["lib"]
22
- spec.required_ruby_version = '>= 1.8.7'
23
-
24
- spec.rdoc_options = ["--line-numbers", "--title", "Bitly", "--main", "README.md"]
25
- spec.extra_rdoc_files = ["LICENSE.md", "README.md"]
26
-
27
- spec.add_runtime_dependency "multi_json", "~> 1.3"
28
- spec.add_runtime_dependency "httparty", ">= 0.7.6"
8
+ spec.name = "bitly"
9
+ spec.version = Bitly::VERSION
10
+ spec.authors = ["Phil Nash"]
11
+ spec.email = ["philnash@gmail.com"]
12
+
13
+ spec.summary = %q{Use the Bitly API to shorten or expand URLs}
14
+ spec.description = %q{Use the Bitly API version 4 to shorten or expand URLs. Check out the API documentation at https://dev.bitly.com/.}
15
+ spec.homepage = "https://github.com/philnash/bitly"
16
+ spec.license = "MIT"
17
+
18
+ spec.metadata = {
19
+ "bug_tracker_uri" => "https://github.com/philnash/bitly/issues",
20
+ "changelog_uri" => "https://github.com/philnash/bitly/blob/master/History.txt",
21
+ "documentation_uri" => "https://www.rubydoc.info/gems/bitly/",
22
+ "homepage_uri" => "https://github.com/philnash/bitly",
23
+ "source_code_uri" => "https://github.com/philnash/bitly"
24
+ }
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features|bin|docs)/})
28
+ end
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.required_ruby_version = ">= 2.3.0"
32
+
29
33
  spec.add_runtime_dependency "oauth2", "< 2.0", ">= 0.5.0"
30
- spec.add_runtime_dependency "rack", "<2" if RUBY_VERSION.to_f < 2.2
31
-
32
- spec.add_development_dependency "bundler", "~> 1.15"
33
- spec.add_development_dependency "rake"
34
- spec.add_development_dependency "shoulda", "~> 3.5.0"
35
- spec.add_development_dependency "flexmock"
36
- spec.add_development_dependency "webmock"
37
- spec.add_development_dependency "minitest", "~> 5.8.3"
34
+
35
+ spec.add_development_dependency "bundler", "~> 2.0"
36
+ spec.add_development_dependency "rake", "~> 13.0"
37
+ spec.add_development_dependency "rspec", "~> 3.0"
38
+ spec.add_development_dependency "simplecov", "~> 0.17.1"
39
+ spec.add_development_dependency "webmock", "~> 3.7.6"
40
+ spec.add_development_dependency "vcr"
41
+ spec.add_development_dependency "envyable"
38
42
  end
@@ -0,0 +1,5 @@
1
+ CLIENT_ID:
2
+ CLIENT_SECRET:
3
+ OAUTH_CODE:
4
+ USERNAME:
5
+ PASSWORD:
@@ -1,8 +1,10 @@
1
- require 'multi_json'
1
+ # frozen_string_literal: true
2
2
 
3
- require 'bitly/config'
4
- require 'bitly/utils'
5
- require 'bitly/client'
6
- require 'bitly/url'
7
- require 'bitly/version'
8
- require 'bitly/v3'
3
+ require "bitly/version"
4
+
5
+ module Bitly
6
+ autoload :Error, "bitly/error"
7
+ autoload :OAuth, "bitly/oauth"
8
+ autoload :HTTP, "bitly/http"
9
+ autoload :API, "bitly/api"
10
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ require "uri"
3
+
4
+ module Bitly
5
+ module API
6
+ BASE_URL = URI("https://api-ssl.bitly.com/v4")
7
+
8
+ autoload :Base, File.join(File.dirname(__FILE__), "api/base.rb")
9
+ autoload :Client, File.join(File.dirname(__FILE__), "api/client.rb")
10
+ autoload :ClickMetric, File.join(File.dirname(__FILE__), "api/click_metric.rb")
11
+ autoload :Bitlink, File.join(File.dirname(__FILE__), "api/bitlink.rb")
12
+ autoload :Organization, File.join(File.dirname(__FILE__), "api/organization.rb")
13
+ autoload :Group, File.join(File.dirname(__FILE__), "api/group.rb")
14
+ autoload :User, File.join(File.dirname(__FILE__), "api/user.rb")
15
+ autoload :BSD, File.join(File.dirname(__FILE__), "api/bsd.rb")
16
+ autoload :OAuthApp, File.join(File.dirname(__FILE__), "api/oauth_app.rb")
17
+ autoload :ShortenCounts, File.join(File.dirname(__FILE__), "api/shorten_counts.rb")
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ require "time"
3
+
4
+ module Bitly
5
+ module API
6
+ module Base
7
+ attr_reader :response
8
+
9
+ def assign_attributes(attributes)
10
+ if self.class.respond_to?(:attributes)
11
+ self.class.attributes.each do |attr|
12
+ instance_variable_set("@#{attr}", attributes[attr.to_s]) if attributes[attr.to_s]
13
+ end
14
+ end
15
+ if self.class.respond_to?(:time_attributes)
16
+ self.class.time_attributes.each do |attr|
17
+ instance_variable_set("@#{attr}", Time.parse(attributes[attr.to_s])) if attributes[attr.to_s]
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,342 @@
1
+ # frozen_string_literal: true
2
+ require_relative "./base"
3
+ require_relative "./list"
4
+
5
+ module Bitly
6
+ module API
7
+ ##
8
+ # A Bitlink represents a shortened link within Bitly.
9
+ class Bitlink
10
+ autoload :PaginatedList, File.join(File.dirname(__FILE__), "bitlink/paginated_list.rb")
11
+ autoload :Deeplink, File.join(File.dirname(__FILE__), "bitlink/deeplink.rb")
12
+ autoload :ClicksSummary, File.join(File.dirname(__FILE__), "bitlink/clicks_summary.rb")
13
+ autoload :LinkClick, File.join(File.dirname(__FILE__), "bitlink/link_click.rb")
14
+
15
+ include Base
16
+
17
+ class List < Bitly::API::List ; end
18
+
19
+ ##
20
+ # Shortens a long url.
21
+ # [`POST /v4/shorten`](https://dev.bitly.com/v4/#operation/createBitlink)
22
+ #
23
+ # @example
24
+ # bitlink = Bitly::API::Bitlink.shorten(client: client, long_url: long_url)
25
+ #
26
+ # @param client [Bitly::API::Client] An authorized API client
27
+ # @param long_url [String] A long URL that you want shortened
28
+ # @param domain [String] The bitly domain you want to shorten, API default
29
+ # is "bit.ly"
30
+ # @param group_guid [String] The GUID of the group for which you want to
31
+ # shorten this URL
32
+ #
33
+ # @return [Bitly::API::Bitlink]
34
+ def self.shorten(client:, long_url:, domain: nil, group_guid: nil)
35
+ response = client.request(
36
+ path: "/shorten",
37
+ method: "POST",
38
+ params: {
39
+ "long_url" => long_url,
40
+ "domain" => domain,
41
+ "group_guid" => group_guid
42
+ })
43
+ new(data: response.body, client: client, response: response)
44
+ end
45
+
46
+ ##
47
+ # Creates a new Bitlink from a long URL. Similar to #shorten but takes
48
+ # more parameters.
49
+ # [`POST /v4/bitlinks`](https://dev.bitly.com/v4/#operation/createFullBitlink)
50
+ #
51
+ # @example
52
+ # bitlink = Bitly::API::Bitlink.create(client: client, long_url: long_url)
53
+ #
54
+ # @param client [Bitly::API::Client] An authorized API client
55
+ # @param long_url [String] A long URL that you want shortened
56
+ # @param domain [String] The bitly domain you want to shorten, API default
57
+ # is "bit.ly"
58
+ # @param group_guid [String] The GUID of the group for which you want to
59
+ # shorten this URL
60
+ # @param title [String] A descriptive title for the link
61
+ # @param tags [Array<String>] Some tags for the Bitlink
62
+ # @param deeplinks [Array<Bitly::API::Bitlink::Deeplink>]
63
+ #
64
+ # @return [Bitly::API::Bitlink]
65
+ def self.create(client:, long_url:, domain: nil, group_guid: nil, title: nil, tags: nil, deeplinks: nil)
66
+ response = client.request(
67
+ path: "/bitlinks",
68
+ method: "POST",
69
+ params: {
70
+ "long_url" => long_url,
71
+ "domain" => domain,
72
+ "group_guid" => group_guid,
73
+ "title" => title,
74
+ "tags" => tags,
75
+ "deeplinks" => deeplinks
76
+ }
77
+ )
78
+ new(data: response.body, client: client, response: response)
79
+ end
80
+
81
+ ##
82
+ # Return information about a bitlink
83
+ # [`GET /v4/bitlink/{bitlink}`](https://dev.bitly.com/v4/#operation/getBitlink)
84
+ #
85
+ # @example
86
+ # bitlink = Bitly::API::Bitlink.fetch(client: client, bitlink: "bit.ly/example")
87
+ #
88
+ # @param client [Bitly::API::Client] An authorized API client
89
+ # @param bitlink [String] The bitlink you want information about
90
+ #
91
+ # @return [Bitly::API::Bitlink]
92
+ def self.fetch(client:, bitlink:)
93
+ response = client.request(path: "/bitlinks/#{bitlink}")
94
+ new(data: response.body, client: client, response: response)
95
+ end
96
+
97
+ ##
98
+ # Return public information about a bitlink
99
+ # [`POST /v4/expand`](https://dev.bitly.com/v4/#operation/expandBitlink)
100
+ #
101
+ # @example
102
+ # bitlink = Bitly::API::Bitlink.expand(client: client, bitlink: "bit.ly/example")
103
+ #
104
+ # @param client [Bitly::API::Client] An authorized API client
105
+ # @param bitlink [String] The bitlink you want information about
106
+ #
107
+ # @return [Bitly::API::Bitlink]
108
+ def self.expand(client:, bitlink:)
109
+ response = client.request(path: "/expand", method: "POST", params: { "bitlink_id" => bitlink })
110
+ new(data: response.body, client: client, response: response)
111
+ end
112
+
113
+ ##
114
+ # Retrieve a list of bitlinks by group
115
+ # [`GET /v4/groups/{group_guid}/bitlinks`](https://dev.bitly.com/v4/#operation/getBitlinksByGroup)
116
+ #
117
+ # @example
118
+ # bitlinks = Bitly::API::Bitlink.list(client: client, group_guid: guid)
119
+ #
120
+ # @param client [Bitly::API::Client] An authorized API client
121
+ # @param group_guid [String] The group guid for which you want bitlinks
122
+ # @param size [Integer] The number of Bitlinks to return, max 100
123
+ # @param page [Integer] The page of bitlinks to request
124
+ # @param keyword [String] Custom keyword to filter on history entries
125
+ # @param query [String] A value to search for Bitlinks
126
+ # @param created_before [Integer] Timestamp as an integer unix epoch
127
+ # @param created_after [Integer] Timestamp as an integer unix epoch
128
+ # @param modified_after [Integer] Timestamp as an integer unix epoch
129
+ # @param archived [String] Whether or not to include archived Bitlinks.
130
+ # One of "on", "off" or "both". Defaults to "off".
131
+ # @param deeplinks [String] Filter to only Bitlinks that contain
132
+ # deeplinks. One of "on", "off" or "both". Defaults to "both".
133
+ # @param domain_deeplinks [String] Filter to only Bitlinks that contain
134
+ # deeplinks configured with a custom domain. One of "on", "off" or
135
+ # "both". Defaults to "both".
136
+ # @param campaign_guid [String] Filter to return only links for the given
137
+ # campaign GUID, can be provided
138
+ # @param channel_guid [String] Filter to return only links for the given
139
+ # channel GUID, can be provided, overrides all other parameters
140
+ # @param custom_bitlink [String] Filter to return only custom Bitlinks.
141
+ # One of "on", "off" or "both". Defaults to "both".
142
+ # @param tags [Array<String>] Filter by the given tags.
143
+ # @param encoding_login [Array<String>] Filter by the login of the
144
+ # authenticated user that created the Bitlink.
145
+ #
146
+ # @return [Bitly::API::Bitlink::PaginatedList]
147
+ def self.list(
148
+ client:,
149
+ group_guid:,
150
+ size: nil,
151
+ page: nil,
152
+ keyword: nil,
153
+ query: nil,
154
+ created_before: nil,
155
+ created_after: nil,
156
+ modified_after: nil,
157
+ archived: nil,
158
+ deeplinks: nil,
159
+ domain_deeplinks: nil,
160
+ campaign_guid: nil,
161
+ channel_guid: nil,
162
+ custom_bitlink: nil,
163
+ tags: nil,
164
+ encoding_login: nil
165
+ )
166
+ params = {
167
+ "size" => size,
168
+ "page" => page,
169
+ "keyword" => keyword,
170
+ "query" => query,
171
+ "created_before" => created_before,
172
+ "created_after" => created_after,
173
+ "modified_after" => modified_after,
174
+ "archived" => archived,
175
+ "deeplinks" => deeplinks,
176
+ "domain_deeplinks" => domain_deeplinks,
177
+ "campaign_guid" => campaign_guid,
178
+ "channel_guid" => channel_guid,
179
+ "custom_bitlink" => custom_bitlink,
180
+ "tags" => tags,
181
+ "encoding_login" => encoding_login
182
+ }
183
+ response = client.request(path: "/groups/#{group_guid}/bitlinks", params: params)
184
+ bitlinks = response.body["links"].map do |link|
185
+ new(data: link, client: client)
186
+ end
187
+ PaginatedList.new(items: bitlinks, response: response, client: client)
188
+ end
189
+
190
+ ##
191
+ # Returns a list of Bitlinks sorted by clicks.
192
+ # [`GET /v4/groups/{group_guid}/bitlinks/{sort}`](https://dev.bitly.com/v4/#operation/getSortedBitlinks)
193
+ #
194
+ # The API returns a separate list of the links and the click counts, but
195
+ # this method assigns the number of clicks for each link to the Bitlink
196
+ # object and sorts the resulting list in descending order.
197
+ #
198
+ # Sorted lists are not paginated, so do not have any pagination detail.
199
+ #
200
+ # @example
201
+ # links = Bitly::API::Bitlink.sorted_list(client: client, group_guid: guid)
202
+ #
203
+ # @param client [Bitly::API::Client] An authorized API client
204
+ # @param group_guid [String] The group for which you want to return links
205
+ # @param sort [String] The data to sort on. Default and only option is
206
+ # "clicks".
207
+ # @param unit [String] A unit of time. Default is "day" and can be
208
+ # "minute", "hour", "day", "week" or "month"
209
+ # @param units [Integer] An integer representing the time units to query
210
+ # data for. pass -1 to return all units of time. Defaults to -1.
211
+ # @param unit_reference [String] An ISO-8601 timestamp, indicating the
212
+ # most recent time for which to pull metrics. Will default to current
213
+ # time.
214
+ # @param size [Integer] The number of links to be returned. Defaults to 50
215
+ #
216
+ # @returns [Bitly::API::Bitlink::List]
217
+ def self.sorted_list(client:, group_guid:, sort: "clicks", unit: nil, units: nil, unit_reference: nil, size: nil)
218
+ params = {
219
+ "unit" => unit,
220
+ "units" => units,
221
+ "unit_reference" => unit_reference,
222
+ "size" => size
223
+ }
224
+ response = client.request(path: "/groups/#{group_guid}/bitlinks/#{sort}", params: params)
225
+ link_clicks = response.body["sorted_links"]
226
+ bitlinks = response.body["links"].map do |link|
227
+ clicks = link_clicks.find { |c| c["id"] == link["id"] }["clicks"]
228
+ new(data: link, client: client, clicks: clicks)
229
+ end.sort { |a, b| b.clicks <=> a.clicks }
230
+ List.new(items: bitlinks, response: response)
231
+ end
232
+
233
+ def self.attributes
234
+ [:archived, :tags, :title, :created_by, :long_url, :client_id, :custom_bitlinks, :link, :id]
235
+ end
236
+ def self.time_attributes
237
+ [:created_at]
238
+ end
239
+ attr_reader(*(attributes + time_attributes))
240
+ attr_reader :deeplinks, :clicks
241
+
242
+ def initialize(data:, client:, response: nil, clicks: nil)
243
+ assign_attributes(data)
244
+ if data["deeplinks"]
245
+ @deeplinks = data["deeplinks"].map { |data| Deeplink.new(data: data) }
246
+ else
247
+ @deeplinks = []
248
+ end
249
+ @clicks = clicks
250
+ @client = client
251
+ @response = response
252
+ end
253
+
254
+ ##
255
+ # Update the Bitlink.
256
+ # [`PATCH /v4/bitlink/{bitlink}`](https://dev.bitly.com/v4/#operation/updateBitlink)
257
+ #
258
+ # The parameters listed below are from the documentation. Some only work
259
+ # if you have a Bitly Pro account.
260
+ #
261
+ # @example
262
+ # bitlink.update(title: "New title")
263
+ #
264
+ # @param archived [Boolean]
265
+ # @param tags [Array<String>]
266
+ # @param created_at [String]
267
+ # @param title [String]
268
+ # @param deeplinks [Array<Bitly::API::Bitlink::Deeplink>]
269
+ # @param created_by [String]
270
+ # @param long_url [String]
271
+ # @param client_id [String]
272
+ # @param custom_bitlinks [Array<String>]
273
+ # @param link [String]
274
+ # @param id [String]
275
+ # @param references [Hash<String, String>]
276
+ #
277
+ # @returns [Bitly::API::Bitlink]
278
+ def update(
279
+ archived: nil,
280
+ tags: nil,
281
+ created_at: nil,
282
+ title: nil,
283
+ deeplinks: nil,
284
+ created_by: nil,
285
+ long_url: nil,
286
+ client_id: nil,
287
+ custom_bitlinks: nil,
288
+ link: nil,
289
+ id: nil,
290
+ references: nil
291
+ )
292
+ @response = @client.request(
293
+ path: "/bitlinks/#{@id}",
294
+ method: "PATCH",
295
+ params: {
296
+ "archived" => archived,
297
+ "tags" => tags,
298
+ "created_at" => created_at,
299
+ "title" => title,
300
+ "deeplinks" => deeplinks,
301
+ "created_by" => created_by,
302
+ "long_url" =>long_url ,
303
+ "client_id" => client_id,
304
+ "custom_bitlinks" => custom_bitlinks,
305
+ "link" => link,
306
+ "id" => id,
307
+ "references" => references
308
+ }
309
+ )
310
+ assign_attributes(@response.body)
311
+ self
312
+ end
313
+
314
+ # [`GET /v4/bitlink/{bitlink}/clicks/summary`](https://dev.bitly.com/v4/#operation/getClicksSummaryForBitlink)
315
+ #
316
+ # @return [Bitly::API::Bitlink::ClicksSummary]
317
+ def clicks_summary(unit: nil, units: nil, unit_reference: nil, size: nil)
318
+ ClicksSummary.fetch(client: @client, bitlink: id, unit: unit, units: units, unit_reference: unit_reference, size: size)
319
+ end
320
+
321
+ ##
322
+ # Get the clicks for the bitlink.
323
+ # [`GET /v4/bitlink/{bitlink}/clicks`](https://dev.bitly.com/v4/#operation/getClicksForBitlink)
324
+ #
325
+ # @param sort [String] The data to sort on. Default and only option is
326
+ # "clicks".
327
+ # @param unit [String] A unit of time. Default is "day" and can be
328
+ # "minute", "hour", "day", "week" or "month"
329
+ # @param units [Integer] An integer representing the time units to query
330
+ # data for. pass -1 to return all units of time. Defaults to -1.
331
+ # @param unit_reference [String] An ISO-8601 timestamp, indicating the
332
+ # most recent time for which to pull metrics. Will default to current
333
+ # time.
334
+ # @param size [Integer] The number of links to be returned. Defaults to 50
335
+ #
336
+ # @return [Bitly::API::Bitlink::LinkClick::List]
337
+ def link_clicks(unit: nil, units: nil, unit_reference: nil, size: nil)
338
+ LinkClick.list(client: @client, bitlink: id, unit: unit, units: units, unit_reference: unit_reference, size: size)
339
+ end
340
+ end
341
+ end
342
+ end