relinkly 1.0.1 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62e19675647abf66a3224c35a5f6bd8f9f091e8364d09bfd31f7302a1a097652
4
- data.tar.gz: 81604d5824117d10be52b756df585e08187e5613f7d788f9490f201a5bd76a39
3
+ metadata.gz: 65d72a34b49919ac9b5ba4ab0e832ef4e64a15c9876c90a6e7d71b9add7e213f
4
+ data.tar.gz: a81194a39f7995adab36df320ebd508a72adfc6d2e14fb416a6aae075a513b01
5
5
  SHA512:
6
- metadata.gz: 881108d64d8453895389e51fc4dd2e7892ec3913659e47c88138d0d5f5c36a445557060611e371bc44b69d54ee1bc9875e880f23d5929dc292683be3d2df7520
7
- data.tar.gz: 56330896dd5aa3b5de153c74fdc8e382ccd9ab8b505094ae0f48a886752f891a46c7af711f8c7fb2a68c5a160af2fcb9168e0b570b3e21cc4f9489c078e8a78d
6
+ metadata.gz: bddef48388d44413b2896894e8d16c8868a93479fb4e461969fe57b1c078bfbbeb4ea3d4eab1c320991c95fd7a3530e61c91d20d3a99ae849bdf5495f7e85cca
7
+ data.tar.gz: db3060d654fd2fbad01786e922200cf797f20db7f6c3470184e05c5837961cb20f3c67238d7909595a794b5b14d097437e04583cd307ab9cb396976986225c84
data/.gitignore CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  /.bundle/
3
2
  /.yardoc
4
3
  /Gemfile.lock
@@ -9,3 +8,4 @@
9
8
  /spec/reports/
10
9
  /tmp/
11
10
  *.gem
11
+ .idea
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # relinkly
1
+ # relinkly [![Gem Version](https://badge.fury.io/rb/relinkly.svg)](https://badge.fury.io/rb/relinkly)
2
2
 
3
3
  ## Installation
4
4
 
@@ -57,7 +57,7 @@ api.delete_tag(id, options) # DELETE /v1/tags/:id
57
57
  #### Links
58
58
  ```ruby
59
59
  api.links # GET /v1/links
60
- api.links(id) # GET /v1/links/:id
60
+ api.link(id) # GET /v1/links/:id
61
61
  api.link_count(options) # GET /v1/links/count
62
62
  api.new_link(options) # GET /v1/links/new
63
63
  api.shorten(destination, options) # POST /v1/links
@@ -66,7 +66,7 @@ api.delete_link(id, options) # DELETE /v1/links/:id
66
66
  api.tags_link(id, options) # GET /v1/links/:id/tags
67
67
  ```
68
68
 
69
- #### Make a new branded short link
69
+ #### Creating your branded short link!
70
70
 
71
71
  ```ruby
72
72
  my_domain = api.domains.first
@@ -74,8 +74,9 @@ link = api.shorten('https://google.com', domain: my_domain.to_h, title: 'Google'
74
74
  ```
75
75
 
76
76
  #### Workspace workaround
77
- Please see the applicable methods for options available when making requests. In case of new link creation, default workspace is selected if workspace isn't mentioned explictly.
78
- Please pass the workspace_id in the options as follows in case you want to create branded link to another workspace.
77
+ Please see the applicable methods for options available when making requests. You need to pass the workspace_id in the options as follows in case you want to perform operations other than the default workspace.
78
+
79
+ Here's how you can create a link into another workspace.
79
80
 
80
81
  ```ruby
81
82
  my_domain = api.domains.first
@@ -83,7 +84,9 @@ my_workspace_id = api.workspaces.first.id
83
84
  link = api.shorten('https://google.com', domain: my_domain.to_h, title: 'Google', description: 'Google Homepage', workspace: my_workspace_id)
84
85
  ```
85
86
 
86
- Please note that `my_domain` should already be included inside `my_workspace`. You can find all the details about your workspace by going here. https://app.rebrandly.com/workspaces
87
+ Please note that `my_domain` should already be included inside `my_workspace`. Similarly other operations on link and tags can be achieved as above.
88
+
89
+ You can find all the details about your workspace by going here. https://app.rebrandly.com/workspaces
87
90
 
88
91
 
89
92
  ## Contributing
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
- require 'relinkly'
4
+ require "bundler/setup"
5
+ require "relinkly"
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -11,5 +11,5 @@ require 'relinkly'
11
11
  # require "pry"
12
12
  # Pry.start
13
13
 
14
- require 'irb'
14
+ require "irb"
15
15
  IRB.start
data/lib/relinkly/api.rb CHANGED
@@ -11,7 +11,13 @@ module Relinkly
11
11
  API_VERSION = 'v1'
12
12
  BASE_URL = "https://api.rebrandly.com/#{API_VERSION}"
13
13
 
14
+ ########################################
15
+ # ACCOUNT / WORKSPACES
16
+ ########################################
17
+ #
14
18
  # ACCOUNT ENDPOINTS
19
+ #
20
+ ########################################
15
21
 
16
22
  # GET /v1/account
17
23
  def account
@@ -19,17 +25,25 @@ module Relinkly
19
25
  end
20
26
 
21
27
  # WORKSPACES ENDPOINTS
28
+ #
29
+ ########################################
22
30
 
23
31
  # GET /v1/account/workspaces
24
- def workspaces(options = {})
25
- all_workspaces = relinkly_request(:get, 'account/workspaces', options)
32
+ def workspaces(options: {})
33
+ all_workspaces = relinkly_request(:get, 'workspaces', options)
26
34
  all_workspaces.map { |workspace| Workspace.new(workspace) }
27
35
  end
28
36
 
37
+ ########################################
38
+ # REBRANDLY OPS
39
+ ########################################
40
+ #
29
41
  # DOMAINS ENDPOINTS
42
+ #
43
+ ########################################
30
44
 
31
45
  # GET /v1/domains
32
- def domains(options = {})
46
+ def domains(options: {})
33
47
  all_domains = relinkly_request(:get, 'domains', options)
34
48
  all_domains.map { |domain| Domain.new(domain) }
35
49
  end
@@ -40,14 +54,16 @@ module Relinkly
40
54
  end
41
55
 
42
56
  # GET /v1/domains/count
43
- def domain_count(_options = {})
57
+ def domain_count(_options: {})
44
58
  relinkly_request(:get, 'domains/count')['count']
45
59
  end
46
60
 
47
61
  # TAGS ENDPOINTS
62
+ #
63
+ ########################################
48
64
 
49
65
  # GET /v1/tags
50
- def tags(options = {})
66
+ def tags(options: {})
51
67
  all_tags = relinkly_request(:get, 'tags', options)
52
68
  all_tags.map { |tag| Tag.new(tag) }
53
69
  end
@@ -58,30 +74,32 @@ module Relinkly
58
74
  end
59
75
 
60
76
  # GET /v1/tags/count
61
- def tag_count(_options = {})
77
+ def tag_count(_options: {})
62
78
  relinkly_request(:get, 'tags/count')['count']
63
79
  end
64
80
 
65
81
  # POST /v1/tags
66
- def new_tag(destination, options = {})
82
+ def new_tag(destination, options: {})
67
83
  options[:destination] = destination
68
84
  Tag.new(relinkly_request(:post, 'tags', options))
69
85
  end
70
86
 
71
87
  # POST /v1/tags/:id
72
- def update_tag(id, options = {})
88
+ def update_tag(id, options: {})
73
89
  Tag.new(relinkly_request(:post, "tags/#{id}", options))
74
90
  end
75
91
 
76
92
  # DELETE /v1/tags/:id
77
- def delete_tag(id, options = {})
93
+ def delete_tag(id, options: {})
78
94
  Tag.new(relinkly_request(:delete, "tags/#{id}", options))
79
95
  end
80
96
 
81
97
  # LINKS ENDPOINTS
98
+ #
99
+ ########################################
82
100
 
83
101
  # GET /v1/links
84
- def links(options = {})
102
+ def links(options: {})
85
103
  all_links = relinkly_request(:get, 'links', options)
86
104
  all_links.map { |link| Link.new(link) }
87
105
  end
@@ -97,7 +115,7 @@ module Relinkly
97
115
  end
98
116
 
99
117
  # POST /v1/links
100
- def shorten(destination, options = {})
118
+ def shorten(destination, options: {})
101
119
  options[:destination] = destination
102
120
  Link.new(relinkly_request(:post, 'links', options))
103
121
  end
@@ -112,10 +130,61 @@ module Relinkly
112
130
  Link.new(relinkly_request(:delete, "links/#{id}", options))
113
131
  end
114
132
 
133
+ # DELETE /v1/links
134
+ def delete_links(options: {})
135
+ Link.new(relinkly_request(:delete, 'links', options))
136
+ end
137
+
138
+ # GET /v1/links/:id/tags
115
139
  def tags_link(id, options = {})
116
140
  Link.new(relinkly_request(:get, "/links/#{id}/tags", options))
117
141
  end
118
142
 
143
+ # POST /v1/links/:id/tags/:tag
144
+ def add_tags_link(id, tag, options: {})
145
+ Link.new(relinkly_request(:post, "/links/#{id}/tags/#{tag}", options))
146
+ end
147
+
148
+ # DELETE /v1/links/:id/tags/:tag
149
+ def delete_tags_link(id, tag, options: {})
150
+ Link.new(relinkly_request(:delete, "/links/#{id}/tags/#{tag}", options))
151
+ end
152
+
153
+ # GET /v1/links/:id/scripts
154
+ def scripts_link(id, options: {})
155
+ Link.new(relinkly_request(:get, "/links/#{id}/scripts", options))
156
+ end
157
+
158
+ # POST /v1/links/:id/scripts/:script
159
+ def add_scripts_link(id, script, options: {})
160
+ Link.new(relinkly_request(:post, "/links/#{id}/scripts/#{script}", options))
161
+ end
162
+
163
+ # DELETE /v1/links/:id/scripts/:script
164
+ def delete_scripts_link(id, script, options: {})
165
+ Link.new(relinkly_request(:delete, "/links/#{id}/scripts/#{script}", options))
166
+ end
167
+
168
+ # SCRIPTS ENDPOINTS
169
+ #
170
+ ########################################
171
+
172
+ # GET /v1/scripts
173
+ def scripts(options: {})
174
+ all_scripts = relinkly_request(:get, 'scripts', options)
175
+ all_scripts.map { |script| Script.new(script) }
176
+ end
177
+
178
+ # GET /v1/scripts/:id
179
+ def script(id)
180
+ Script.new(relinkly_request(:get, "scripts/#{id}"))
181
+ end
182
+
183
+ # GET /v1/scripts/count
184
+ def script_count(_options: {})
185
+ relinkly_request(:get, 'scripts/count')['count']
186
+ end
187
+
119
188
  private
120
189
 
121
190
  def relinkly_request(method, url, options = {})
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Relinkly
4
4
  class Domain < Element
5
- attr_accessor :id, :ref, :full_name, :top_level_domain, :level,
6
- :created_at, :updated_at, :custom_homepage, :owner_id, :type,
7
- :subdomains, :managed, :status, :https, :active
5
+ attr_accessor :id, :ref, :full_name, :top_level_domain, :level, :created_at, :updated_at,
6
+ :custom_homepage, :owner_id, :type, :subdomains, :managed, :status, :https,
7
+ :active
8
8
  end
9
9
  end
data/lib/relinkly/link.rb CHANGED
@@ -2,11 +2,9 @@
2
2
 
3
3
  module Relinkly
4
4
  class Link < Element
5
- attr_accessor :id, :link_id, :title, :slashtag, :destination, :created_at,
6
- :updated_at, :status, :tags, :scripts, :forward_parameters,
7
- :clicks, :last_click_date, :last_click_at, :is_public,
8
- :short_url, :domain_id, :domain_name,
9
- :https, :favourite
5
+ attr_accessor :id, :link_id, :title, :slashtag, :destination, :created_at, :updated_at, :status,
6
+ :tags, :scripts, :forward_parameters, :clicks, :last_click_date, :last_click_at,
7
+ :is_public, :short_url, :domain_id, :domain_name, :https, :favourite
10
8
 
11
9
  # Associations
12
10
  %i[domain creator integration].each do |association|
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Relinkly
4
+ class Script < Element
5
+ attr_accessor :id, :name, :uri
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Relinkly
4
- VERSION = '1.0.1'
4
+ VERSION = '1.1.0'
5
5
  end
data/lib/relinkly.rb CHANGED
@@ -10,6 +10,7 @@ require 'relinkly/integration'
10
10
  require 'relinkly/link'
11
11
  require 'relinkly/workspace'
12
12
  require 'relinkly/tag'
13
+ require 'relinkly/script'
13
14
 
14
15
  module Relinkly
15
16
  class << self
data/relinkly.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "relinkly"
8
8
  spec.version = Relinkly::VERSION
9
9
  spec.authors = ["Rajan Bhattarai"]
10
- spec.email = ["hey@rajanbhattarai.com"]
10
+ spec.email = ["rajan@rajanbhattarai.com"]
11
11
 
12
12
  spec.summary = "A Ruby wrapper for the Rebrandly API "
13
13
  spec.description = "Easily create short links on your ruby apps using Rebrandly API."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relinkly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajan Bhattarai
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-01 00:00:00.000000000 Z
11
+ date: 2025-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,14 +68,13 @@ dependencies:
68
68
  version: 0.18.1
69
69
  description: Easily create short links on your ruby apps using Rebrandly API.
70
70
  email:
71
- - hey@rajanbhattarai.com
71
+ - rajan@rajanbhattarai.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
- - ".travis.yml"
79
78
  - Gemfile
80
79
  - LICENSE.txt
81
80
  - README.md
@@ -90,6 +89,7 @@ files:
90
89
  - lib/relinkly/element.rb
91
90
  - lib/relinkly/integration.rb
92
91
  - lib/relinkly/link.rb
92
+ - lib/relinkly/script.rb
93
93
  - lib/relinkly/tag.rb
94
94
  - lib/relinkly/version.rb
95
95
  - lib/relinkly/workspace.rb
@@ -98,7 +98,7 @@ homepage: https://github.com/cdrrazan/relinkly
98
98
  licenses:
99
99
  - MIT
100
100
  metadata: {}
101
- post_install_message:
101
+ post_install_message:
102
102
  rdoc_options: []
103
103
  require_paths:
104
104
  - lib
@@ -113,8 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubygems_version: 3.1.4
117
- signing_key:
116
+ rubygems_version: 3.4.17
117
+ signing_key:
118
118
  specification_version: 4
119
119
  summary: A Ruby wrapper for the Rebrandly API
120
120
  test_files: []
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.6
5
- before_install: gem install bundler -v 2.2.3