Class: Linketysplit::PublicationSdk
- Inherits:
-
Object
- Object
- Linketysplit::PublicationSdk
- Defined in:
- lib/linketysplit/publication_sdk.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Class Method Summary collapse
- .get_linketysplit_enabled_meta_tag(enabled: true) ⇒ Object
- .get_linketysplit_pricing_meta_tag(article_pricing) ⇒ Object
Instance Method Summary collapse
-
#create_article_purchase_link(permalink, custom_pricing = nil, context = nil) ⇒ String
Creates a signed article purchase link with the given permalink.
-
#initialize(api_key) ⇒ PublicationSdk
constructor
A new instance of PublicationSdk.
Constructor Details
#initialize(api_key) ⇒ PublicationSdk
Returns a new instance of PublicationSdk.
9 10 11 |
# File 'lib/linketysplit/publication_sdk.rb', line 9 def initialize(api_key) @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/linketysplit/publication_sdk.rb', line 7 def api_key @api_key end |
Class Method Details
.get_linketysplit_enabled_meta_tag(enabled: true) ⇒ Object
41 42 43 44 |
# File 'lib/linketysplit/publication_sdk.rb', line 41 def self.(enabled: true) content = enabled ? "true" : "false" "<meta property=\"linketysplit:enabled\" content=\"#{content}\" />" end |
.get_linketysplit_pricing_meta_tag(article_pricing) ⇒ Object
36 37 38 39 |
# File 'lib/linketysplit/publication_sdk.rb', line 36 def self.(article_pricing) content = Base64.encode64(JSON.dump(article_pricing)) "<meta property=\"linketysplit:pricing\" content=\"#{content}\" />" end |
Instance Method Details
#create_article_purchase_link(permalink, custom_pricing = nil, context = nil) ⇒ String
Creates a signed article purchase link with the given permalink.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/linketysplit/publication_sdk.rb', line 24 def create_article_purchase_link(permalink, custom_pricing=nil, context=nil) payload = { permalink: } payload[:customPricing] = custom_pricing if custom_pricing payload[:context] = context if context token = JWT.encode payload, @api_key, "HS256" "https://linketysplit.com/purchase-link/#{token}" end |