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 +5 -5
- data/.circleci/config.yml +45 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/README.md +32 -4
- data/lib/branch_io/client.rb +5 -0
- data/lib/branch_io/client/links.rb +30 -0
- data/lib/branch_io/client/response.rb +10 -0
- data/lib/branch_io/version.rb +1 -1
- metadata +4 -5
- data/.travis.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7a81bf76ea664bdcf8b02806cef5e906cc48b21f70a4bc758e44e154939f50fd
|
4
|
+
data.tar.gz: d92062aa427f81d7dcbe03bc0ad28a833da800a46670f945f1e5e0f28d3cc5e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/.rspec
CHANGED
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
|
+
[](https://rubygems.org/gems/branch_io)
|
4
|
+
[](https://rubygems.org/gems/branch_io)
|
5
|
+
[](https://github.com/ushu/branch_io/blob/master/LICENSE)
|
6
|
+
<!-- [](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
|
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!`:
|
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!`:
|
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
|
-
|
data/lib/branch_io/client.rb
CHANGED
@@ -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
|
data/lib/branch_io/version.rb
CHANGED
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.
|
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:
|
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
|
-
|
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
|
data/.travis.yml
DELETED