Class: Mailersend::SMSRecipient

Inherits:
Object
  • Object
show all
Defined in:
lib/mailersend/sms_recipient/sms_recipient.rb

Overview

SMS Recipient endpoint from MailerSend API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client = Mailersend::Client.new) ⇒ SMSRecipient

Returns a new instance of SMSRecipient.



13
14
15
16
17
18
19
20
# File 'lib/mailersend/sms_recipient/sms_recipient.rb', line 13

def initialize(client = Mailersend::Client.new)
  @client = client
  @status = status
  @sms_number_id = sms_number_id
  @sms_recipient_id = sms_recipient_id
  @page = page
  @limit = limit
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/mailersend/sms_recipient/sms_recipient.rb', line 6

def client
  @client
end

#limitObject

Returns the value of attribute limit.



6
7
8
# File 'lib/mailersend/sms_recipient/sms_recipient.rb', line 6

def limit
  @limit
end

#pageObject

Returns the value of attribute page.



6
7
8
# File 'lib/mailersend/sms_recipient/sms_recipient.rb', line 6

def page
  @page
end

#sms_number_idObject

Returns the value of attribute sms_number_id.



6
7
8
# File 'lib/mailersend/sms_recipient/sms_recipient.rb', line 6

def sms_number_id
  @sms_number_id
end

#sms_recipient_idObject

Returns the value of attribute sms_recipient_id.



6
7
8
# File 'lib/mailersend/sms_recipient/sms_recipient.rb', line 6

def sms_recipient_id
  @sms_recipient_id
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/mailersend/sms_recipient/sms_recipient.rb', line 6

def status
  @status
end

Instance Method Details

#get(sms_recipient_id:) ⇒ Object



32
33
34
# File 'lib/mailersend/sms_recipient/sms_recipient.rb', line 32

def get(sms_recipient_id:)
  client.http.get("#{MAILERSEND_API_URL}/sms-recipients/#{sms_recipient_id}")
end

#list(page: nil, limit: nil) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/mailersend/sms_recipient/sms_recipient.rb', line 22

def list(page: nil, limit: nil)
  hash = {
    'page' => page,
    'limit' => limit
  }

  client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/sms-recipients',
                                   query: URI.encode_www_form(hash)))
end

#update(sms_recipient_id:, status: nil) ⇒ Object



36
37
38
39
40
41
# File 'lib/mailersend/sms_recipient/sms_recipient.rb', line 36

def update(sms_recipient_id:, status: nil)
  hash = {
    'status' => status
  }
  client.http.put("#{MAILERSEND_API_URL}/sms-recipients/#{sms_recipient_id}", json: hash.compact)
end