module BranchIO::Client::Links
Constants
- LINK_PATH
Public Instance Methods
delete_link(url)
click to toggle source
# File lib/branch_io/client/links.rb, line 125 def delete_link(url) ensure_branch_secret_defined! # Build the request URL encoded_url = URI.encode_www_form_component(url) delete_url = "#{LINK_PATH}?url=#{encoded_url}" # Build the request body delete_json = { branch_key: self.branch_key, branch_secret: self.branch_secret } # Call branch.io public API raw_response = self.delete(delete_url, delete_json) # Wrap the result in a Response if raw_response.success? LinkDeletedResponse.new(raw_response) else ErrorResponse.new(raw_response) end end
delete_link!(url)
click to toggle source
# File lib/branch_io/client/links.rb, line 119 def delete_link!(url) res = delete_link(url) res.validate! res end
link(options = {})
click to toggle source
# File lib/branch_io/client/links.rb, line 14 def link(options = {}) # Load and check the link properties link_properties = BranchIO::LinkProperties.wrap(options) # Build the request defaults = { sdk: :api, branch_key: self.branch_key } link_json = defaults.merge(link_properties.as_json) # Call branch.io public API raw_response = self.post(LINK_PATH, link_json) # Wrap the result in a Response if raw_response.success? UrlResponse.new(raw_response) else ErrorResponse.new(raw_response) end end
link!(options = {})
click to toggle source
# File lib/branch_io/client/links.rb, line 8 def link!(options = {}) res = link(options) res.validate! res end
link_info(url)
click to toggle source
# File lib/branch_io/client/links.rb, line 102 def link_info(url) # Build the request URL encoded_url = URI.encode_www_form_component(url) encoded_key = URI.encode_www_form_component(branch_key) show_url = "#{LINK_PATH}?url=#{encoded_url}&branch_key=#{encoded_key}" # Call branch.io public API raw_response = self.get(show_url) # Wrap the result in a Response if raw_response.success? LinkPropertiesResponse.new(raw_response) else ErrorResponse.new(raw_response) end end
link_info!(options = {})
click to toggle source
# File lib/branch_io/client/links.rb, line 96 def link_info!(options = {}) res = link_info(options) res.validate! res end
links(options = [])
click to toggle source
# File lib/branch_io/client/links.rb, line 42 def links(options = []) # Load and check the links properties link_properties_array = options.map { |o| BranchIO::LinkProperties.wrap(o) } # Build the request links_url = "#{LINK_PATH}/bulk/#{self.branch_key}" links_json = link_properties_array.map(&:as_json) # Call branch.io public API raw_response = self.post(links_url, links_json) # Wrap the result in a Response if raw_response.success? BulkUrlsResponse.new(raw_response) else ErrorResponse.new(raw_response) end end
links!(options = {})
click to toggle source
# File lib/branch_io/client/links.rb, line 36 def links!(options = {}) res = links(options) res.validate! res end
update_link(url, options = {})
click to toggle source
# File lib/branch_io/client/links.rb, line 67 def update_link(url, options = {}) ensure_branch_secret_defined! # Load and check the links configuration properties link_properties = BranchIO::LinkProperties.wrap(options) # Build the request URL encoded_url = URI.encode_www_form_component(url) update_url = "#{LINK_PATH}?url=#{encoded_url}" # Build the request body defaults = { sdk: :api, branch_key: self.branch_key, branch_secret: self.branch_secret } update_json = defaults.merge(link_properties.as_json) # Call branch.io public API raw_response = self.put(update_url, update_json) # Wrap the result in a Response if raw_response.success? LinkPropertiesResponse.new(raw_response) else ErrorResponse.new(raw_response) end end
update_link!(options = {})
click to toggle source
# File lib/branch_io/client/links.rb, line 61 def update_link!(options = {}) res = update_link(options) res.validate! res end