Class: BranchIO::Client
- Inherits:
-
Object
- Object
- BranchIO::Client
- Includes:
- Links, HTTParty
- Defined in:
- lib/branch_io/client.rb,
lib/branch_io/client/links.rb,
lib/branch_io/client/response.rb
Defined Under Namespace
Modules: Links Classes: BulkUrlsResponse, ErrorApiCallFailed, ErrorMissingBranchKey, ErrorResponse, LinkDeletedResponse, LinkPropertiesResponse, Response, UrlResponse
Constant Summary
Constants included from Links
Instance Attribute Summary collapse
-
#branch_key ⇒ Object
readonly
Basic Api client.
-
#branch_secret ⇒ Object
readonly
Basic Api client.
Instance Method Summary collapse
- #delete(url, data = {}) ⇒ Object
- #get(url) ⇒ Object
-
#initialize(branch_key = ENV["BRANCH_KEY"], branch_secret = ENV["BRANCH_SECRET"]) ⇒ Client
constructor
A new instance of Client.
- #post(url, data = {}) ⇒ Object
- #put(url, data = {}) ⇒ Object
Methods included from Links
#delete_link, #delete_link!, #link, #link!, #link_info, #link_info!, #links, #links!, #update_link, #update_link!
Constructor Details
#initialize(branch_key = ENV["BRANCH_KEY"], branch_secret = ENV["BRANCH_SECRET"]) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 26 27 |
# File 'lib/branch_io/client.rb', line 20 def initialize(branch_key = ENV["BRANCH_KEY"], branch_secret = ENV["BRANCH_SECRET"]) @branch_key = branch_key @branch_secret = branch_secret unless branch_key raise ErrorMissingBranchKey, "No Branch Key found: please provided one such key to BranchIO::Client#initialize or by setting the BRANCH_KEY environment variable" end end |
Instance Attribute Details
#branch_key ⇒ Object (readonly)
Basic Api client
19 20 21 |
# File 'lib/branch_io/client.rb', line 19 def branch_key @branch_key end |
#branch_secret ⇒ Object (readonly)
Basic Api client
19 20 21 |
# File 'lib/branch_io/client.rb', line 19 def branch_secret @branch_secret end |
Instance Method Details
#delete(url, data = {}) ⇒ Object
43 44 45 46 |
# File 'lib/branch_io/client.rb', line 43 def delete(url, data = {}) body = data.to_json self.class.delete(url, body: body, headers: default_headers) end |
#get(url) ⇒ Object
29 30 31 |
# File 'lib/branch_io/client.rb', line 29 def get(url) self.class.get(url, headers: default_headers) end |
#post(url, data = {}) ⇒ Object
33 34 35 36 |
# File 'lib/branch_io/client.rb', line 33 def post(url, data = {}) body = data.to_json self.class.post(url, body: body, headers: default_headers) end |
#put(url, data = {}) ⇒ Object
38 39 40 41 |
# File 'lib/branch_io/client.rb', line 38 def put(url, data = {}) body = data.to_json self.class.put(url, body: body, headers: default_headers) end |