This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
150 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
require "addressable/uri" | ||
require "httparty" | ||
|
||
module LinkshareAPI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require "addressable/uri" | ||
|
||
module LinkshareAPI | ||
# For implementation details please visit | ||
# https://rakutenlinkshare.zendesk.com/hc/en-us/articles/201295755-Guide-to-Deep-Linking | ||
class DeepLinking | ||
attr_reader :base_url, :affiliate_id | ||
|
||
def initialize | ||
@affiliate_id = LinkshareAPI.affiliate_id | ||
@base_url = LinkshareAPI::WEB_SERVICE_URIS[:deep_linking] | ||
|
||
if @affiliate_id.nil? | ||
raise AuthenticationError.new( | ||
"No Affilite ID. Set your Affiliate ID by using 'LinkshareAPI.affiliate_id = <AFFILIATE_ID>'. " + | ||
"See https://github.com/rmarescu/linkshare_api#deep-linking for details." | ||
) | ||
end | ||
end | ||
|
||
def build(mid, murl) | ||
raise ArgumentError, "mid must be a Fixnum, got #{mid.class} instead" unless mid.is_a?(Fixnum) | ||
|
||
uri = Addressable::URI.parse(base_url) | ||
uri.query_values = { | ||
id: affiliate_id, | ||
mid: mid, | ||
murl: murl | ||
} | ||
uri.to_s | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
require "addressable/uri" | ||
require "cgi" | ||
require "httparty" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require "logger" | ||
|
||
module LinkshareAPI | ||
class Logger | ||
attr_reader :logger | ||
|
||
def self.log(level, message) | ||
|
||
new.logger.send(level, "[linkshare_api] #{message}") | ||
end | ||
|
||
def initialize | ||
@logger = LinkshareAPI.logger || ::Logger.new(STDOUT) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
require "addressable/uri" | ||
require "httparty" | ||
|
||
module LinkshareAPI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module LinkshareAPI | ||
VERSION = "0.2.0" | ||
VERSION = "0.3.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters