branch_io 0.2.0 → 0.3.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
- SHA1:
3
- metadata.gz: 52055a70b4c8c8037f42010e08bfc77c6978c68f
4
- data.tar.gz: 9ae189b23d59056108a8ace997ea8f8e37e07697
2
+ SHA256:
3
+ metadata.gz: 7a81bf76ea664bdcf8b02806cef5e906cc48b21f70a4bc758e44e154939f50fd
4
+ data.tar.gz: d92062aa427f81d7dcbe03bc0ad28a833da800a46670f945f1e5e0f28d3cc5e8
5
5
  SHA512:
6
- metadata.gz: 1e09d7d9674a92e6e8f73b5af47e8eedf594982f0b88923e1dc3385bef16c874ed4a590a78ca33e30ec65a797fc7a3cf9e78c4c210dfe27edd098c496ca8bf18
7
- data.tar.gz: 4db7f87336d7b7495066f467cb723b08be1f581367728e235b01f70f23dc4ec8fee922cdd8b2ce13c753d6479706354a529f067621541223677f7ea85db31146
6
+ metadata.gz: 47546d905112a07cbcc2ff7fe2369357a0b6a0cd8405fcd460ba563a1efd1df372bf48c78ce026852b783e138d8cb2640104f3d33b67dd11ee2c7ea7c6c13d65
7
+ data.tar.gz: bc51dd049d60a0b80ad9ca86653e23296027a984dd25cc11870ccb5814efab0dc2b9141c4f505ebc9185d49bb4fabfb4309e20019a2181a544d37bcc64b7166b
@@ -0,0 +1,45 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.4.2
11
+
12
+ working_directory: ~/repo
13
+
14
+ steps:
15
+ - checkout
16
+
17
+ # Download and cache dependencies
18
+ - restore_cache:
19
+ keys:
20
+ - v1-dependencies-{{ checksum "Gemfile" }}
21
+ # fallback to using the latest cache if no exact match is found
22
+ - v1-dependencies-
23
+
24
+ - run:
25
+ name: install dependencies
26
+ command: |
27
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
28
+
29
+ - save_cache:
30
+ paths:
31
+ - ./venv
32
+ key: v1-dependencies-{{ checksum "Gemfile" }}
33
+
34
+ # run tests!
35
+ - run:
36
+ name: run tests
37
+ command: |
38
+ bundle exec rake
39
+
40
+ # collect reports
41
+ - store_test_results:
42
+ path: ~/repo/test-results
43
+ - store_artifacts:
44
+ path: ~/repo/test-results
45
+ destination: test-results
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  .idea/
11
11
  .DS_Store
12
12
  .idea/
13
+ test-results
data/.rspec CHANGED
@@ -1,3 +1,5 @@
1
1
  --require spec_helper
2
2
  --format documentation
3
3
  --color
4
+ --format RspecJunitFormatter
5
+ --out test-results/rspec/rspec.xml
data/README.md CHANGED
@@ -1,7 +1,15 @@
1
1
  # A Ruby wrapper for the [branch.io](http://branch.io) [public API](https://github.com/BranchMetrics/branch-deep-linking-public-api)
2
2
 
3
+ [![Gem](https://img.shields.io/gem/v/branch_io.svg?style=flat)](https://rubygems.org/gems/branch_io)
4
+ [![Downloads](https://img.shields.io/gem/dt/branch_io.svg?style=flat)](https://rubygems.org/gems/branch_io)
5
+ [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/ushu/branch_io/blob/master/LICENSE)
6
+ <!-- [![CircleCI](https://img.shields.io/circleci/project/github/ushu/branch_io.svg)](https://circleci.com/gh/ushu/branch_io) -->
7
+
8
+ Please see the [Branch documentation](https://docs.branch.io) for general information. Please report any
9
+ problems by opening issues in this repo.
10
+
3
11
  This is a simple [HTTparty](https://github.com/jnunemaker/httparty)-based gem for accessing the branch.io REST APIs,
4
- as descried [here](https://github.com/BranchMetrics/branch-deep-linking-public-api).
12
+ as described [here](https://github.com/BranchMetrics/branch-deep-linking-public-api). See the [Branch API documentation](https://docs.branch.io/pages/apps/api/) for further details.
5
13
 
6
14
  It follows the exact design of the original REST API: basically links are resources you can generate and update,
7
15
  provided you hold the required credentials.
@@ -130,7 +138,7 @@ end
130
138
  _The only difference between `#links` and `#links!` is that the latter version will
131
139
  raise a new `BranchIO::ErrorApiCallFailed` exception in case of an error._
132
140
 
133
- ### `Client#link_info` and `Client#link_info!`: Registers a [new deep linking URL](https://github.com/BranchMetrics/branch-deep-linking-public-api#creating-a-deep-linking-url)
141
+ ### `Client#link_info` and `Client#link_info!`: Returns information about a [deep linking URL](https://github.com/BranchMetrics/branch-deep-linking-public-api#creating-a-deep-linking-url)
134
142
 
135
143
  **BEWARE: this method requires the BRANCH_SECRET to be defined**
136
144
 
@@ -151,7 +159,7 @@ end
151
159
  **The only difference between `#link_info` and `#link_info!` is that the latter version will
152
160
  raise a new `BranchIO::ErrorApiCallFailed` exception in case of an error.**
153
161
 
154
- ### `Client#update_link` and `Client#update_link!`: Registers a [new deep linking URL](https://github.com/BranchMetrics/branch-deep-linking-public-api#creating-a-deep-linking-url)
162
+ ### `Client#update_link` and `Client#update_link!`: Updates a [deep linking URL](https://github.com/BranchMetrics/branch-deep-linking-public-api#creating-a-deep-linking-url)
155
163
 
156
164
  **BEWARE: this method requires the BRANCH_SECRET to be defined**
157
165
 
@@ -173,6 +181,27 @@ end
173
181
  **The only difference between `#update_link` and `#update_link!` is that the latter version will
174
182
  raise a new `BranchIO::ErrorApiCallFailed` exception in case of an error.**
175
183
 
184
+ ### `Client#delete_link` and `Client#delete_link!`: Deletes a [deep linking URL](https://github.com/BranchMetrics/branch-deep-linking-public-api#creating-a-deep-linking-url)
185
+
186
+ **BEWARE: this method requires the BRANCH_SECRET to be defined**
187
+
188
+ This method deletes an existing link and returns the URL and deletion confirmation.
189
+
190
+ ```ruby
191
+ # Call the service
192
+ res = client.delete_link("https://...")
193
+
194
+ # Inspect the server response
195
+ if res.success?
196
+ puts "Successfully deleted link: #{res.link_deleted.to_json['url']}"
197
+ else
198
+ puts "Error updating link info: #{res.error}"
199
+ end
200
+ ```
201
+
202
+ **The only difference between `#delete_link` and `#delete_link!` is that the latter version will
203
+ raise a new `BranchIO::ErrorApiCallFailed` exception in case of an error.**
204
+
176
205
  ## Development
177
206
 
178
207
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -194,4 +223,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/ushu/b
194
223
  ## License
195
224
 
196
225
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
197
-
@@ -40,6 +40,11 @@ module BranchIO
40
40
  self.class.put(url, body: body, headers: default_headers)
41
41
  end
42
42
 
43
+ def delete(url, data = {})
44
+ body = data.to_json
45
+ self.class.delete(url, body: body, headers: default_headers)
46
+ end
47
+
43
48
  private
44
49
 
45
50
  def ensure_branch_secret_defined!
@@ -115,6 +115,36 @@ module BranchIO
115
115
  ErrorResponse.new(raw_response)
116
116
  end
117
117
  end
118
+
119
+ def delete_link!(url)
120
+ res = delete_link(url)
121
+ res.validate!
122
+ res
123
+ end
124
+
125
+ def delete_link(url)
126
+ ensure_branch_secret_defined!
127
+
128
+ # Build the request URL
129
+ encoded_url = URI.encode_www_form_component(url)
130
+ delete_url = "#{LINK_PATH}?url=#{encoded_url}"
131
+
132
+ # Build the request body
133
+ delete_json = {
134
+ branch_key: self.branch_key,
135
+ branch_secret: self.branch_secret
136
+ }
137
+
138
+ # Call branch.io public API
139
+ raw_response = self.delete(delete_url, delete_json)
140
+
141
+ # Wrap the result in a Response
142
+ if raw_response.success?
143
+ LinkDeletedResponse.new(raw_response)
144
+ else
145
+ ErrorResponse.new(raw_response)
146
+ end
147
+ end
118
148
  end
119
149
  end
120
150
  end
@@ -107,5 +107,15 @@ module BranchIO
107
107
  @link_properties ||= BranchIO::LinkProperties.new(json)
108
108
  end
109
109
  end
110
+
111
+ class LinkDeletedResponse < Response
112
+ def success?
113
+ json["deleted"] == true
114
+ end
115
+
116
+ def url
117
+ json["url"]
118
+ end
119
+ end
110
120
  end
111
121
  end
@@ -1,3 +1,3 @@
1
1
  module BranchIO
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: branch_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aurélien Noce
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-17 00:00:00.000000000 Z
11
+ date: 2020-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -158,11 +158,11 @@ executables: []
158
158
  extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
+ - ".circleci/config.yml"
161
162
  - ".gitignore"
162
163
  - ".rspec"
163
164
  - ".rubocop.yml"
164
165
  - ".ruby-version"
165
- - ".travis.yml"
166
166
  - CODE_OF_CONDUCT.md
167
167
  - Gemfile
168
168
  - LICENSE.txt
@@ -196,8 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  requirements: []
199
- rubyforge_project:
200
- rubygems_version: 2.6.14
199
+ rubygems_version: 3.0.8
201
200
  signing_key:
202
201
  specification_version: 4
203
202
  summary: A Client for the Branch.io deep linking public API
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.2