lib/branch_io/client.rb in branch_io-0.1.0 vs lib/branch_io/client.rb in branch_io-0.2.0

- old
+ new

@@ -3,11 +3,10 @@ # Submodules (hold the api method calls) require_relative "client/links" module BranchIO - class Client class ErrorMissingBranchKey < StandardError; end # Submodules include Links @@ -16,46 +15,44 @@ include HTTParty base_uri "https://api.branch.io" # Basic Api client attr_reader :branch_key, :branch_secret - def initialize(branch_key=ENV["BRANCH_KEY"], branch_secret=ENV["BRANCH_SECRET"]) + 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.new("No Branch Key found: please provided one such key to BranchIO::Client#initialize or by setting the BRANCH_KEY environment variable") + 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 def get(url) self.class.get(url, headers: default_headers) end - def post(url, data={}) + def post(url, data = {}) body = data.to_json self.class.post(url, body: body, headers: default_headers) end - def put(url, data={}) + def put(url, data = {}) body = data.to_json self.class.put(url, body: body, headers: default_headers) end private def ensure_branch_secret_defined! unless branch_secret - raise ErrorMissingBranchKey.new("No Branch Secret found: please provided one such key to BranchIO::Client#initialize or by setting the BRANCH_SECRET environment variable") + 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 def default_headers { "Content-Type" => "application/json", "Accept" => "application/json" } end - end - end