bitly 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/sonarcloud.yml +4 -8
- data/.github/workflows/tests.yml +1 -1
- data/History.txt +6 -0
- data/README.md +34 -24
- data/lib/bitly/api/base.rb +1 -1
- data/lib/bitly/api/bitlink/paginated_list.rb +7 -41
- data/lib/bitly/api/bitlink.rb +2 -5
- data/lib/bitly/api/client.rb +12 -0
- data/lib/bitly/api/group.rb +10 -1
- data/lib/bitly/api/paginated_list.rb +61 -0
- data/lib/bitly/api/qrcode/paginated_list.rb +18 -0
- data/lib/bitly/api/qrcode/scans_summary.rb +34 -0
- data/lib/bitly/api/qrcode.rb +104 -0
- data/lib/bitly/api.rb +1 -0
- data/lib/bitly/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c3f7e8ce05cc1176818efa7b83c94fd1e6f6bcc7ce4caefdfc7f719aab18bbd9
|
|
4
|
+
data.tar.gz: 38593047cf4f4b02b6e45a457cce9d698e3f11b3bc06337d1ebcc0953ba1cb28
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34f1f1d76f0f984f4ba22069aee1280332c1fe5deead1bb2572257dad0ebbb8a97e9c7e642d4270bc495fe5aafde7ba6ce7e98980685e4a37ecbec58b74ad074
|
|
7
|
+
data.tar.gz: 4f772f32325b0fc59c76ceef45634aee7ea0f0c4a81985051ca09286b4c570c92077cb1e05b233c2d8287987ffb3636f6386a125e214810b20837adc86509662
|
|
@@ -4,9 +4,9 @@ on:
|
|
|
4
4
|
- main
|
|
5
5
|
pull_request:
|
|
6
6
|
types: [opened, synchronize, reopened]
|
|
7
|
-
name:
|
|
7
|
+
name: SonarQube Analysis
|
|
8
8
|
jobs:
|
|
9
|
-
|
|
9
|
+
sonarqube:
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
steps:
|
|
12
12
|
- uses: actions/checkout@v2
|
|
@@ -23,12 +23,8 @@ jobs:
|
|
|
23
23
|
run: bundle exec rspec
|
|
24
24
|
env:
|
|
25
25
|
COVERAGE: json
|
|
26
|
-
- name:
|
|
27
|
-
|
|
28
|
-
run: |
|
|
29
|
-
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.json
|
|
30
|
-
- name: SonarCloud Scan
|
|
31
|
-
uses: sonarsource/sonarcloud-github-action@master
|
|
26
|
+
- name: SonarQube Scan
|
|
27
|
+
uses: SonarSource/sonarqube-scan-action@v5.0.0
|
|
32
28
|
env:
|
|
33
29
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
34
30
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
data/.github/workflows/tests.yml
CHANGED
data/History.txt
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
=== Ongoing
|
|
2
2
|
|
|
3
|
+
=== 3.1.0 / 2025-02-18
|
|
4
|
+
|
|
5
|
+
* Adds `Qrcode` class and methods to fetch qrcodes and list qrcodes by group as well as get a summary of scans and retrieve an image
|
|
6
|
+
* Adds Ruby 3.4 to test matrix
|
|
7
|
+
* Updates to latest SonarQube scanner
|
|
8
|
+
|
|
3
9
|
=== 3.0.0 / 2022-11-08
|
|
4
10
|
|
|
5
11
|
* **Breaking** Removes Group DELETE and Oauth Apps endpoints
|
data/README.md
CHANGED
|
@@ -4,27 +4,29 @@ A Ruby gem for using the version 4 [Bitly API](https://dev.bitly.com/) to shorte
|
|
|
4
4
|
|
|
5
5
|
[](https://rubygems.org/gems/bitly)  [](https://codeclimate.com/github/philnash/bitly/maintainability) [](https://sonarcloud.io/summary/new_code?id=philnash_bitly) [](https://inch-ci.org/github/philnash/bitly)
|
|
6
6
|
|
|
7
|
-
* [
|
|
8
|
-
* [
|
|
9
|
-
* [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* [
|
|
14
|
-
* [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* [
|
|
23
|
-
|
|
24
|
-
* [
|
|
25
|
-
* [
|
|
26
|
-
* [
|
|
27
|
-
* [
|
|
7
|
+
* [Bitly](#bitly)
|
|
8
|
+
* [Installation](#installation)
|
|
9
|
+
* [Usage](#usage)
|
|
10
|
+
* [Authentication](#authentication)
|
|
11
|
+
* [Creating an API client](#creating-an-api-client)
|
|
12
|
+
* [Shorten a link](#shorten-a-link)
|
|
13
|
+
* [Expand a link](#expand-a-link)
|
|
14
|
+
* [Available API Endpoints](#available-api-endpoints)
|
|
15
|
+
* [Groups](#groups)
|
|
16
|
+
* [Organizations](#organizations)
|
|
17
|
+
* [Users](#users)
|
|
18
|
+
* [Bitlinks](#bitlinks)
|
|
19
|
+
* [QR codes](#qr-codes)
|
|
20
|
+
* [Custom Bitlinks](#custom-bitlinks)
|
|
21
|
+
* [Campaigns](#campaigns)
|
|
22
|
+
* [BSDs (Branded Short Domains)](#bsds-branded-short-domains)
|
|
23
|
+
* [Webhooks](#webhooks)
|
|
24
|
+
* [Customising HTTP requests](#customising-http-requests)
|
|
25
|
+
* [Build your own adapter](#build-your-own-adapter)
|
|
26
|
+
* [Development](#development)
|
|
27
|
+
* [Contributing](#contributing)
|
|
28
|
+
* [License](#license)
|
|
29
|
+
* [Code of Conduct](#code-of-conduct)
|
|
28
30
|
|
|
29
31
|
## Installation
|
|
30
32
|
|
|
@@ -48,6 +50,8 @@ $ gem install bitly
|
|
|
48
50
|
|
|
49
51
|
## Usage
|
|
50
52
|
|
|
53
|
+
For a quick introduction, read this blog post on [how to use the Bitly API in Ruby](https://philna.sh/blog/2022/11/09/how-to-use-the-bitly-api-in-ruby/).
|
|
54
|
+
|
|
51
55
|
### Authentication
|
|
52
56
|
|
|
53
57
|
All API endpoints require authentication with an OAuth token. You can get your own OAuth token from the [Bitly console](https://app.bitly.com/). Click on the account drop down menu, then _Profile Settings_ then _Generic Access Token_. Fill in your password and you can generate an OAuth access token.
|
|
@@ -105,6 +109,7 @@ This gem supports the following active v4 API endpoints for the[Bitly API](https
|
|
|
105
109
|
- [x] [Retrieve group shorten counts (`GET /v4/groups/{group_guid}/shorten_counts`)](https://dev.bitly.com/api-reference/#getGroupShortenCounts)
|
|
106
110
|
- [x] [Retrieve click metrics for a group by referring networks (`GET /v4/groups/{group_guid}/referring_networks`)](https://dev.bitly.com/api-reference/#GetGroupMetricsByReferringNetworks)
|
|
107
111
|
- [x] [Retrieve click metrics for a group by countries (`GET /v4/groups/{group_guid}/countries`)](https://dev.bitly.com/api-reference/#getGroupMetricsByCountries)
|
|
112
|
+
- [X] [Retrieve QR codes for a group (`GET /v4/groups/{group_guid}/qr-codes`)](https://dev.bitly.com/api-reference/#listQRMinimal)
|
|
108
113
|
- [ ] __[premium]__ [Retrieve click metrics for a group by city (`GET /v4/groups/{group_guid}/cities`)](https://dev.bitly.com/api-reference/#getGroupMetricsByCities)
|
|
109
114
|
- [ ] __[premium]__ [Get group overrides (`GET /v4/groups/{group_guid}/overrides`)](https://dev.bitly.com/api-reference/#getOverridesForGroups)
|
|
110
115
|
|
|
@@ -141,9 +146,14 @@ This gem supports the following active v4 API endpoints for the[Bitly API](https
|
|
|
141
146
|
- [x] [Get metrics for a Bitlink by referrers by domain (`GET /v4/bitlinks/{bitlink}/referrers_by_domains`)](https://dev.bitly.com/api-reference/#getMetricsForBitlinkByReferrersByDomains)
|
|
142
147
|
- [ ] __[premium]__ [Get metrics for a Bitlink by city (`GET /v4/bitlinks/{bitlink}/cities`)](https://dev.bitly.com/api-reference/#getMetricsForBitlinkByCities)
|
|
143
148
|
- [ ] __[premium]__ [Get metrics for a Bitlink by device type (`GET /v4/bitlinks/{bitlink}/devices`)](https://dev.bitly.com/api-reference/#getMetricsForBitlinkByDevices)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
|
|
150
|
+
### QR codes
|
|
151
|
+
|
|
152
|
+
[QR codes documentation](docs/qrcodes.md)
|
|
153
|
+
|
|
154
|
+
- [x] [Retrieve a QR code (`GET /v4/qr-codes/{qrcode_id}`)](https://dev.bitly.com/api-reference/#getQRCodeByIdPublic)
|
|
155
|
+
- [x] [Retrieve the scans summary for a QR code (`GET /v4/qr-codes/{qrcode_id}/scans/summary`)](https://dev.bitly.com/api-reference/#getScanMetricsSummaryForQRCode)
|
|
156
|
+
- [x] [Retrieve a QR code image (`GET /v4/qr-codes/{qrcode_id}/image`)](https://dev.bitly.com/api-reference/#getQRCodeImagePublic)
|
|
147
157
|
|
|
148
158
|
### Custom Bitlinks
|
|
149
159
|
|
data/lib/bitly/api/base.rb
CHANGED
|
@@ -1,52 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "uri"
|
|
2
|
+
require_relative "../paginated_list"
|
|
4
3
|
|
|
5
4
|
module Bitly
|
|
6
5
|
module API
|
|
7
6
|
class Bitlink
|
|
8
|
-
class PaginatedList < Bitly::API::
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def initialize(items:, response: , client:)
|
|
12
|
-
super(items: items, response: response)
|
|
13
|
-
@client = client
|
|
14
|
-
if response.body["pagination"]
|
|
15
|
-
pagination = response.body["pagination"]
|
|
16
|
-
@next_url = pagination["next"]
|
|
17
|
-
@prev_url = pagination["prev"]
|
|
18
|
-
@size = pagination["size"]
|
|
19
|
-
@page = pagination["page"]
|
|
20
|
-
@total = pagination["total"]
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def has_next_page?
|
|
25
|
-
!next_url.nil? && !next_url.empty?
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def has_prev_page?
|
|
29
|
-
!prev_url.nil? && !prev_url.empty?
|
|
7
|
+
class PaginatedList < Bitly::API::PaginatedList
|
|
8
|
+
def item_key
|
|
9
|
+
"links"
|
|
30
10
|
end
|
|
31
11
|
|
|
32
|
-
def
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def prev_page
|
|
37
|
-
has_prev_page? ? get_page(uri: URI(prev_url)) : nil
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
private
|
|
41
|
-
|
|
42
|
-
def get_page(uri:)
|
|
43
|
-
response = @client.request(path: uri.path.gsub(/\/v4/, ""), params: CGI.parse(uri.query))
|
|
44
|
-
bitlinks = response.body["links"].map do |link|
|
|
45
|
-
Bitlink.new(data: link, client: @client)
|
|
46
|
-
end
|
|
47
|
-
self.class.new(items: bitlinks, response: response, client: @client)
|
|
12
|
+
def item_factory(data)
|
|
13
|
+
Bitlink.new(data: data, client: @client)
|
|
48
14
|
end
|
|
49
15
|
end
|
|
50
16
|
end
|
|
51
17
|
end
|
|
52
|
-
end
|
|
18
|
+
end
|
data/lib/bitly/api/bitlink.rb
CHANGED
|
@@ -184,10 +184,7 @@ module Bitly
|
|
|
184
184
|
"encoding_login" => encoding_login
|
|
185
185
|
}
|
|
186
186
|
response = client.request(path: "/groups/#{group_guid}/bitlinks", params: params)
|
|
187
|
-
|
|
188
|
-
new(data: link, client: client)
|
|
189
|
-
end
|
|
190
|
-
PaginatedList.new(items: bitlinks, response: response, client: client)
|
|
187
|
+
PaginatedList.new(response: response, client: client)
|
|
191
188
|
end
|
|
192
189
|
|
|
193
190
|
##
|
|
@@ -361,4 +358,4 @@ module Bitly
|
|
|
361
358
|
end
|
|
362
359
|
end
|
|
363
360
|
end
|
|
364
|
-
end
|
|
361
|
+
end
|
data/lib/bitly/api/client.rb
CHANGED
|
@@ -548,6 +548,18 @@ module Bitly
|
|
|
548
548
|
BSD.list(client: self)
|
|
549
549
|
end
|
|
550
550
|
|
|
551
|
+
##
|
|
552
|
+
# Fetch a qr code by ID
|
|
553
|
+
# [`GET /v4/qr-codes/{qrcode_id}`](https://dev.bitly.com/api-reference/#getQRCodeByIdPublic)
|
|
554
|
+
#
|
|
555
|
+
# @example
|
|
556
|
+
# qrcode = client.qrcode(qrcode_id: "a1b2c3")
|
|
557
|
+
#
|
|
558
|
+
# @return [Bitly::API::Qrcode]
|
|
559
|
+
def qrcode(qrcode_id:)
|
|
560
|
+
Qrcode.fetch(client: self, qrcode_id: qrcode_id)
|
|
561
|
+
end
|
|
562
|
+
|
|
551
563
|
private
|
|
552
564
|
|
|
553
565
|
def default_headers
|
data/lib/bitly/api/group.rb
CHANGED
|
@@ -165,6 +165,15 @@ module Bitly
|
|
|
165
165
|
Bitly::API::Bitlink.list(client: @client, group_guid: guid)
|
|
166
166
|
end
|
|
167
167
|
|
|
168
|
+
##
|
|
169
|
+
# Gets the QR Codes for the group.
|
|
170
|
+
# [`GET /v4/groups/{group_guid}/qr-codes`](https://dev.bitly.com/api-reference/#listQRMinimal)
|
|
171
|
+
#
|
|
172
|
+
# @return [Bitly::API::Qrcode::List]
|
|
173
|
+
def qrcodes
|
|
174
|
+
Bitly::API::Qrcode.list_by_group(client: @client, group_guid: guid)
|
|
175
|
+
end
|
|
176
|
+
|
|
168
177
|
##
|
|
169
178
|
# Gets the referring networks for the group.
|
|
170
179
|
# [`GET /v4/groups/{group_guid}/referring_networks`](https://dev.bitly.com/api-reference/#GetGroupMetricsByReferringNetworks)
|
|
@@ -216,4 +225,4 @@ module Bitly
|
|
|
216
225
|
end
|
|
217
226
|
end
|
|
218
227
|
end
|
|
219
|
-
end
|
|
228
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "cgi"
|
|
3
|
+
require "uri"
|
|
4
|
+
|
|
5
|
+
module Bitly
|
|
6
|
+
module API
|
|
7
|
+
class PaginatedList < Bitly::API::List
|
|
8
|
+
attr_reader :next_url, :prev_url, :size, :page, :total
|
|
9
|
+
|
|
10
|
+
def initialize(response: , client:)
|
|
11
|
+
@client = client
|
|
12
|
+
super(items: items_from_response(response: response), response: response)
|
|
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
|
+
def item_key
|
|
40
|
+
raise NotImplementedError
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def item_factory(item)
|
|
44
|
+
raise NotImplementedError
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def get_page(uri:)
|
|
50
|
+
response = @client.request(path: uri.path.gsub(/\/v4/, ""), params: CGI.parse(uri.query))
|
|
51
|
+
self.class.new(response: response, client: @client)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def items_from_response(response:)
|
|
55
|
+
response.body[item_key].map do |item|
|
|
56
|
+
item_factory(item)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require_relative "../paginated_list"
|
|
3
|
+
|
|
4
|
+
module Bitly
|
|
5
|
+
module API
|
|
6
|
+
class Qrcode
|
|
7
|
+
class PaginatedList < Bitly::API::PaginatedList
|
|
8
|
+
def item_key
|
|
9
|
+
"qr_codes"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def item_factory(data)
|
|
13
|
+
Qrcode.new(data: data, client: @client)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require_relative "../base"
|
|
3
|
+
|
|
4
|
+
module Bitly
|
|
5
|
+
module API
|
|
6
|
+
class Qrcode
|
|
7
|
+
class ScansSummary
|
|
8
|
+
include Base
|
|
9
|
+
|
|
10
|
+
def self.fetch(client:, qrcode_id:, unit: nil, units: nil, unit_reference: nil)
|
|
11
|
+
response = client.request(
|
|
12
|
+
path: "/qr-codes/#{qrcode_id}/scans/summary",
|
|
13
|
+
params: {
|
|
14
|
+
"unit" => unit,
|
|
15
|
+
"units" => units,
|
|
16
|
+
"unit_reference" => unit_reference
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
new(data: response.body, response: response)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.attributes
|
|
23
|
+
[:units, :unit, :unit_reference, :total_scans]
|
|
24
|
+
end
|
|
25
|
+
attr_reader(*attributes)
|
|
26
|
+
|
|
27
|
+
def initialize(data:, response: nil)
|
|
28
|
+
assign_attributes(data)
|
|
29
|
+
@response = response
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "./base"
|
|
4
|
+
require_relative "./list"
|
|
5
|
+
|
|
6
|
+
module Bitly
|
|
7
|
+
module API
|
|
8
|
+
class Qrcode
|
|
9
|
+
autoload :PaginatedList, File.join(File.dirname(__FILE__), "qrcode/paginated_list.rb")
|
|
10
|
+
autoload :ScansSummary, File.join(File.dirname(__FILE__), "qrcode/scans_summary.rb")
|
|
11
|
+
|
|
12
|
+
include Base
|
|
13
|
+
|
|
14
|
+
class List < Bitly::API::List ; end
|
|
15
|
+
|
|
16
|
+
def self.attributes
|
|
17
|
+
[:qrcode_id, :title, :archived, :serialized_content, :long_urls, :bitlink_id, :qr_code_type, :render_customizations]
|
|
18
|
+
end
|
|
19
|
+
def self.time_attributes
|
|
20
|
+
[:created, :updated]
|
|
21
|
+
end
|
|
22
|
+
attr_reader(*(attributes + time_attributes))
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# Retrieves a list of QR codes matching the filter settings. Values are in reverse chronological order. The pagination occurs by calling the next link in the pagination response object.
|
|
26
|
+
# [`GET /v4/groups/{group_guid}/qr-codes`](https://dev.bitly.com/api-reference/#listQRMinimal)
|
|
27
|
+
#
|
|
28
|
+
# @example
|
|
29
|
+
# qrcodes = Bitly::API::Qrcode.list(client: client, group_guid: guid)
|
|
30
|
+
#
|
|
31
|
+
# @param client [Bitly::API::Client] An authorized API client
|
|
32
|
+
# @param group_guid [String] The group guid for which you want qr codes
|
|
33
|
+
# @param size [Integer] The number of QR Codes to return, default 50.
|
|
34
|
+
# @param archived [String] Whether or not to include archived QRCodes.
|
|
35
|
+
# One of "on", "off" or "both". Defaults to "off".
|
|
36
|
+
# @param archived [String] a filter value if the QRCode has any render customizations (like color or shape changes).
|
|
37
|
+
# One of "on", "off" or "both". Defaults to "both".
|
|
38
|
+
#
|
|
39
|
+
# @return [Bitly::API::Qrcode::PaginatedList]
|
|
40
|
+
def self.list_by_group(
|
|
41
|
+
client:,
|
|
42
|
+
group_guid:,
|
|
43
|
+
size: nil,
|
|
44
|
+
archived: nil,
|
|
45
|
+
has_render_customizations: nil
|
|
46
|
+
)
|
|
47
|
+
params = {
|
|
48
|
+
"size" => size,
|
|
49
|
+
"archived" => archived,
|
|
50
|
+
"has_render_customizations" => has_render_customizations
|
|
51
|
+
}
|
|
52
|
+
response = client.request(path: "/groups/#{group_guid}/qr-codes", params: params)
|
|
53
|
+
PaginatedList.new(response: response, client: client)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# Return information about a QR Code
|
|
58
|
+
# [`GET /v4/qr-codes/{qrcode_id}`](https://dev.bitly.com/api-reference/#getQRCodeByIdPublic)
|
|
59
|
+
#
|
|
60
|
+
# @example
|
|
61
|
+
# qrcode = Bitly::API::Qrcode.fetch(client: client, qrcode_id: "a1b2c3")
|
|
62
|
+
#
|
|
63
|
+
# @param client [Bitly::API::Client] An authorized API client
|
|
64
|
+
# @param qrcode_id [String] The qrcode id you want information about
|
|
65
|
+
#
|
|
66
|
+
# @return [Bitly::API::Qrcode]
|
|
67
|
+
def self.fetch(client:, qrcode_id:)
|
|
68
|
+
response = client.request(path: "/qr-codes/#{qrcode_id}")
|
|
69
|
+
new(data: response.body, client: client, response: response)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# [`GET /v4/qr-codes/{qrcode_id}/scans/summary`](https://dev.bitly.com/api-reference/#getScanMetricsForQRCode)
|
|
73
|
+
#
|
|
74
|
+
# @return [Bitly::API::Qrcode::ScansSummary]
|
|
75
|
+
def scans_summary(unit: nil, units: nil, unit_reference: nil)
|
|
76
|
+
ScansSummary.fetch(client: @client, qrcode_id: @qrcode_id, unit: unit, units: units, unit_reference: unit_reference)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
##
|
|
80
|
+
# Return the SVG or PNG image of a QR Code
|
|
81
|
+
# [`GET /v4/qr-codes/{qrcode_id}/image`](https://dev.bitly.com/api-reference/#getQRCodeImagePublic)
|
|
82
|
+
#
|
|
83
|
+
# @param client [Bitly::API::Client] An authorized API client
|
|
84
|
+
# @param format [String] "svg" or "png". Default "svg"
|
|
85
|
+
#
|
|
86
|
+
# @return [String]
|
|
87
|
+
def image(format: nil)
|
|
88
|
+
params = format.nil? ? {} : {format: format}
|
|
89
|
+
response = @client.request(path: "/qr-codes/#{qrcode_id}/image", params: params)
|
|
90
|
+
response.body["qr_code_image"]
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def initialize(data:, client:, response: nil)
|
|
94
|
+
assign_attributes(data)
|
|
95
|
+
@client = client
|
|
96
|
+
@response = response
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def bitlink
|
|
100
|
+
Bitlink.fetch(client: @client, bitlink: @bitlink_id)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
data/lib/bitly/api.rb
CHANGED
|
@@ -9,6 +9,7 @@ module Bitly
|
|
|
9
9
|
autoload :Client, File.join(File.dirname(__FILE__), "api/client.rb")
|
|
10
10
|
autoload :ClickMetric, File.join(File.dirname(__FILE__), "api/click_metric.rb")
|
|
11
11
|
autoload :Bitlink, File.join(File.dirname(__FILE__), "api/bitlink.rb")
|
|
12
|
+
autoload :Qrcode, File.join(File.dirname(__FILE__), "api/qrcode.rb")
|
|
12
13
|
autoload :Organization, File.join(File.dirname(__FILE__), "api/organization.rb")
|
|
13
14
|
autoload :Group, File.join(File.dirname(__FILE__), "api/group.rb")
|
|
14
15
|
autoload :User, File.join(File.dirname(__FILE__), "api/user.rb")
|
data/lib/bitly/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bitly
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Phil Nash
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-02-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: oauth2
|
|
@@ -179,6 +179,10 @@ files:
|
|
|
179
179
|
- lib/bitly/api/group/preferences.rb
|
|
180
180
|
- lib/bitly/api/list.rb
|
|
181
181
|
- lib/bitly/api/organization.rb
|
|
182
|
+
- lib/bitly/api/paginated_list.rb
|
|
183
|
+
- lib/bitly/api/qrcode.rb
|
|
184
|
+
- lib/bitly/api/qrcode/paginated_list.rb
|
|
185
|
+
- lib/bitly/api/qrcode/scans_summary.rb
|
|
182
186
|
- lib/bitly/api/shorten_counts.rb
|
|
183
187
|
- lib/bitly/api/user.rb
|
|
184
188
|
- lib/bitly/error.rb
|
|
@@ -215,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
215
219
|
- !ruby/object:Gem::Version
|
|
216
220
|
version: '0'
|
|
217
221
|
requirements: []
|
|
218
|
-
rubygems_version: 3.
|
|
222
|
+
rubygems_version: 3.5.16
|
|
219
223
|
signing_key:
|
|
220
224
|
specification_version: 4
|
|
221
225
|
summary: Use the Bitly API to shorten or expand URLs
|