class BranchIO::Client
Attributes
branch_key[R]
Basic Api client
branch_secret[R]
Basic Api client
Public Class Methods
new(branch_key = ENV["BRANCH_KEY"], branch_secret = ENV["BRANCH_SECRET"])
click to toggle source
# 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
Public Instance Methods
delete(url, data = {})
click to toggle source
# 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)
click to toggle source
# File lib/branch_io/client.rb, line 29 def get(url) self.class.get(url, headers: default_headers) end
post(url, data = {})
click to toggle source
# 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 = {})
click to toggle source
# 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
Private Instance Methods
default_headers()
click to toggle source
# File lib/branch_io/client.rb, line 56 def default_headers { "Content-Type" => "application/json", "Accept" => "application/json" } end
ensure_branch_secret_defined!()
click to toggle source
# File lib/branch_io/client.rb, line 50 def ensure_branch_secret_defined! unless branch_secret raise ErrorMissingBranchKey, "No Branch Secret found: please provided one such key to BranchIO::Client#initialize or by setting the BRANCH_SECRET environment variable" end end