Class: Talkable::API::Share

Inherits:
Base
  • Object
show all
Defined in:
lib/talkable/api/share.rb

Constant Summary collapse

VIA_FACEBOOK =

social

"facebook"
VIA_FB_MESSAGE =
"facebook_message"
VIA_TWITTER =
"twitter"
VIA_LINKEDIN =
"linkedin"
VIA_WHATSAPP =
"whatsapp"
VIA_SMS =
"sms"
VIA_OTHER =
"other"
SEND_EMAIL =

direct

"email"

Class Method Summary collapse

Methods inherited from Base

get, post, put

Class Method Details

.create(short_url_code, channel) ⇒ Object



18
19
20
21
# File 'lib/talkable/api/share.rb', line 18

def create(short_url_code, channel)
  warn "[DEPRECATION] `create` is deprecated.  Please use `social` or `direct` instead."
  social(short_url_code, channel: channel)
end

.direct(short_url_code, channel: SEND_EMAIL, recipients:, subject: nil, body: nil, reminder: nil) ⇒ Object

Raises:

  • (ArgumentError)


29
30
31
32
33
34
35
36
37
# File 'lib/talkable/api/share.rb', line 29

def direct(short_url_code, channel: SEND_EMAIL, recipients:, subject: nil, body: nil, reminder: nil)
  raise ArgumentError, 'Email is the only supported sharing channel' unless channel == SEND_EMAIL
  post "/offers/#{short_url_code}/shares/#{channel}", {
    recipients: recipients,
    subject: subject,
    body: body,
    reminder: reminder,
  }
end

.social(short_url_code, channel:) ⇒ Object



23
24
25
26
27
# File 'lib/talkable/api/share.rb', line 23

def social(short_url_code, channel:)
  post "/offers/#{short_url_code}/shares/social", {
    channel: channel,
  }
end