relinkly 0.1.0 → 1.0.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: efe951a2ac0f57738160775af7e0ae5d7233527c057eb65fe6b93a96d764fe0b
4
- data.tar.gz: 8676c1129862ca4e14cf50a19ce3020b586298778c058fe7dfe95c6c6f5ffb57
3
+ metadata.gz: 0ef98f2ea27c1567b2293b703fefabf90c70cbce7fbaa3dfbad54429539e5dca
4
+ data.tar.gz: f9185277790a1e86bfccb3a779aa9b4e07986040d64dde19a49df738cb4a281d
5
5
  SHA512:
6
- metadata.gz: 13322191a160fcc770f2d827b01ef63621676e018216204ebba6dbdc3c8ecb2b8925a9d9f15cda10bc8c8605d24bf617def43ac25e215c28319a348344da5df1
7
- data.tar.gz: 798c9c83492adbf68ee0c33c8e6e50e8805df4ec7c11e5d0e428b15e84a07586ba60746e2f5f47386bb7ae06a95831b02ad388f6ecda2f9e900310e66357fbac
6
+ metadata.gz: 2b149562182bc84a107d8279f5beabf470a9dfc95cc3227d97f1ee4553c6d536dcd43c956d4b148e3b686a387a218d249bad6758f79e57c3a90064fd432f920e
7
+ data.tar.gz: 70422410b36a9a0af25558e01413ef0475f4b8ca39d3daa4de18ac90b3fdfabeb9d3856e2898943d3517392f67f306e8fb204ccab503d93c566331296a7ecb63
data/README.md CHANGED
@@ -35,6 +35,26 @@ api = Relinkly::API.new
35
35
 
36
36
  ### API Requests
37
37
 
38
+ #### Account and Workspaces
39
+ ```ruby
40
+ api.domains # GET /v1/domains
41
+ api.domain(id) # GET /v1/domains/:id
42
+ api.domain_count(options) # GET /v1/domains/count
43
+ api.account # GET /v1/account
44
+ api.workspaces # GET /v1/workspaces
45
+ ```
46
+
47
+ #### Tags
48
+ ```ruby
49
+ api.tags # GET /v1/tags
50
+ api.tags(id) # GET /v1/tags/:id
51
+ api.tag_count(options) # GET /v1/tags/count
52
+ api.new_tag(options) # GET /v1/tags/new
53
+ api.update_tag(id, options) # POST /v1/tags/:id
54
+ api.delete_tag(id, options) # DELETE /v1/tags/:id
55
+ ```
56
+
57
+ #### Links
38
58
  ```ruby
39
59
  api.links # GET /v1/links
40
60
  api.links(id) # GET /v1/links/:id
@@ -42,20 +62,30 @@ api.link_count(options) # GET /v1/links/count
42
62
  api.new_link(options) # GET /v1/links/new
43
63
  api.shorten(destination, options) # POST /v1/links
44
64
  api.update_link(id, options) # POST /v1/links/:id
45
- api.delete(id, options) # DELETE /v1/links/:id
46
- api.domains # GET /v1/domains
47
- api.domain(id) # GET /v1/domains/:id
48
- api.domain_count(options) # GET /v1/domains/count
49
- api.account # GET /v1/account
65
+ api.delete_link(id, options) # DELETE /v1/links/:id
66
+ api.tags_link(id, options) # GET /v1/links/:id/tags
67
+ ```
68
+
69
+ ### Make a new branded short link
70
+
71
+ ```ruby
72
+ my_domain = api.domains.first
73
+ link = api.shorten('https://google.com', domain: my_domain.to_h, title: 'Google', description: 'Google Homepage')
50
74
  ```
51
75
 
52
- ### Make a new short link
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 created branded link to another workspace.
53
79
 
54
80
  ```ruby
55
81
  my_domain = api.domains.first
56
- link = api.shorten('https://google.com', domain: my_domain.to_h, title: 'Google', description: 'Google Homepage', favourite: true)
82
+ my_workspace_id = api.workspaces.first.id
83
+ link = api.shorten('https://google.com', domain: my_domain.to_h, title: 'Google', description: 'Google Homepage', workspace: my_workspace_id)
57
84
  ```
58
85
 
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
+
88
+
59
89
  ## Contributing
60
90
 
61
91
  Bug reports and pull requests are welcome on GitHub at https://github.com/cdrrazan/relinkly.
@@ -8,6 +8,8 @@ require 'relinkly/domain'
8
8
  require 'relinkly/creator'
9
9
  require 'relinkly/integration'
10
10
  require 'relinkly/link'
11
+ require 'relinkly/workspace'
12
+ require 'relinkly/tag'
11
13
 
12
14
  module Relinkly
13
15
  class << self
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'httparty'
4
+ require 'pry'
4
5
 
5
6
  module Relinkly
6
7
  class RelinklyError < StandardError; end
@@ -11,6 +12,80 @@ module Relinkly
11
12
  API_VERSION = 'v1'
12
13
  BASE_URL = "https://api.rebrandly.com/#{API_VERSION}"
13
14
 
15
+ ###########################################################
16
+ # ACCOUNT ENDPOINT
17
+ # #########################################################
18
+ # GET /v1/account
19
+ def account
20
+ Creator.new(relinkly_request(:get, 'account'))
21
+ end
22
+
23
+ ###########################################################
24
+ # WORKSPACES ENDPOINTS
25
+ # #########################################################
26
+ # GET /v1/account/workspaces
27
+ def workspaces(options = {})
28
+ all_workspaces = relinkly_request(:get, 'account/workspaces', options)
29
+ all_workspaces.map { |workspace| Workspace.new(workspace) }
30
+ end
31
+
32
+ ###########################################################
33
+ # DOMAINS ENDPOINT
34
+ # #########################################################
35
+ # GET /v1/domains
36
+ def domains(options = {})
37
+ all_domains = relinkly_request(:get, 'domains', options)
38
+ all_domains.map { |domain| Domain.new(domain) }
39
+ end
40
+
41
+ # GET /v1/domains/:id
42
+ def domain(id)
43
+ Domain.new(relinkly_request(:get, "domains/#{id}"))
44
+ end
45
+
46
+ # GET /v1/domains/count
47
+ def domain_count(_options = {})
48
+ relinkly_request(:get, 'domains/count')['count']
49
+ end
50
+
51
+ ###########################################################
52
+ # TAGS ENDPOINT
53
+ # #########################################################
54
+ # GET /v1/tags
55
+ def tags(options = {})
56
+ all_tags = relinkly_request(:get, 'tags', options)
57
+ all_tags.map { |tag| Tag.new(tag) }
58
+ end
59
+
60
+ # GET /v1/tags/:id
61
+ def tag(id)
62
+ Tag.new(relinkly_request(:get, "tags/#{id}"))
63
+ end
64
+
65
+ # GET /v1/tags/count
66
+ def tag_count(_options = {})
67
+ relinkly_request(:get, 'tags/count')['count']
68
+ end
69
+
70
+ # POST /v1/tags
71
+ def new_tag(destination, options = {})
72
+ options[:destination] = destination
73
+ Tag.new(relinkly_request(:post, 'tags', options))
74
+ end
75
+
76
+ # POST /v1/tags/:id
77
+ def update_tag(id, options = {})
78
+ Tag.new(relinkly_request(:post, "tags/#{id}", options))
79
+ end
80
+
81
+ # DELETE /v1/tags/:id
82
+ def delete_tag(id, options = {})
83
+ Tag.new(relinkly_request(:delete, "tags/#{id}", options))
84
+ end
85
+
86
+ ###########################################################
87
+ # LINKS ENDPOINT
88
+ # #########################################################
14
89
  # GET /v1/links
15
90
  def links(options = {})
16
91
  all_links = relinkly_request(:get, 'links', options)
@@ -39,29 +114,12 @@ module Relinkly
39
114
  end
40
115
 
41
116
  # DELETE /v1/links/:id
42
- def delete(id, options = {})
117
+ def delete_link(id, options = {})
43
118
  Link.new(relinkly_request(:delete, "links/#{id}", options))
44
119
  end
45
120
 
46
- # GET /v1/domains
47
- def domains(options = {})
48
- all_domains = relinkly_request(:get, 'domains', options)
49
- all_domains.map { |domain| Domain.new(domain) }
50
- end
51
-
52
- # GET /v1/domains/:id
53
- def domain(id)
54
- Domain.new(relinkly_request(:get, "domains/#{id}"))
55
- end
56
-
57
- # GET /v1/domains/count
58
- def domain_count(_options = {})
59
- relinkly_request(:get, 'domains/count')['count']
60
- end
61
-
62
- # GET /v1/account
63
- def account
64
- Creator.new(relinkly_request(:get, 'account'))
121
+ def tags_link(id, options = {})
122
+ Link.new(relinkly_request(:get, "/links/#{id}/tags", options))
65
123
  end
66
124
 
67
125
  private
@@ -70,8 +128,11 @@ module Relinkly
70
128
  url = "#{BASE_URL}/#{url}"
71
129
  # Convert all hash keys into camel case for Relinkly
72
130
  options = Hash[options.map { |k, v| [k.to_s.relinkly_lower_camelize.to_sym, v] }]
131
+ workspace_id = options[:workspace]
73
132
 
74
- http_attrs = { headers: headers }
133
+ # Passes the Workspace_id into header if the link is to be created into specific workspace
134
+ header_with_workspace = workspace_id.nil? ? headers : headers.merge!('workspace' => workspace_id)
135
+ http_attrs = { headers: header_with_workspace }
75
136
  case method
76
137
  when :get
77
138
  http_attrs.merge!(query: options)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Relinkly
4
+ class Tag < Element
5
+ attr_accessor :id, :name, :color
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Relinkly
4
- VERSION = '0.1.0'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Relinkly
4
+ class Workspace < Element
5
+ attr_accessor :id, :name, :avatarUrl, :links, :teammates,
6
+ :domains, :created_at, :updated_at
7
+ end
8
+ end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["hey@rajanbhattarai.com"]
11
11
 
12
12
  spec.summary = "A Ruby wrapper for the Rebrandly API "
13
- spec.description = "Easily create branded short links in your ruby apps using Rebrandly."
13
+ spec.description = "Easily create short links on your ruby apps using Rebrandly API."
14
14
  spec.homepage = "https://github.com/cdrrazan/relinkly"
15
15
  spec.license = "MIT"
16
16
 
@@ -24,5 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 2.2.3"
25
25
  spec.add_development_dependency "rake", "~> 13.0.3"
26
26
  spec.add_development_dependency "rspec", "~> 3.10.0"
27
+ spec.add_development_dependency "pry", "~> 0.13.1"
27
28
  spec.add_dependency 'httparty', '~> 0.18.1'
28
29
  end
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: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajan Bhattarai
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-30 00:00:00.000000000 Z
11
+ date: 2020-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.10.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.13.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.13.1
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: httparty
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +80,7 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: 0.18.1
69
- description: Easily create branded short links in your ruby apps using Rebrandly.
83
+ description: Easily create short links on your ruby apps using Rebrandly API.
70
84
  email:
71
85
  - hey@rajanbhattarai.com
72
86
  executables: []
@@ -90,7 +104,9 @@ files:
90
104
  - lib/relinkly/element.rb
91
105
  - lib/relinkly/integration.rb
92
106
  - lib/relinkly/link.rb
107
+ - lib/relinkly/tag.rb
93
108
  - lib/relinkly/version.rb
109
+ - lib/relinkly/workspace.rb
94
110
  - relinkly.gemspec
95
111
  homepage: https://github.com/cdrrazan/relinkly
96
112
  licenses: