Class: Mailersend::SMSNumber

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

Overview

SMS Number endpoint from MailerSend API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of SMSNumber.



12
13
14
15
16
17
18
# File 'lib/mailersend/sms_number/sms_number.rb', line 12

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

Instance Attribute Details

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#limitObject

Returns the value of attribute limit.



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

def limit
  @limit
end

#pageObject

Returns the value of attribute page.



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

def page
  @page
end

#pausedObject

Returns the value of attribute paused.



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

def paused
  @paused
end

#sms_number_idObject

Returns the value of attribute sms_number_id.



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

def sms_number_id
  @sms_number_id
end

Instance Method Details

#delete(sms_number_id:) ⇒ Object



41
42
43
# File 'lib/mailersend/sms_number/sms_number.rb', line 41

def delete(sms_number_id:)
  client.http.delete("#{MAILERSEND_API_URL}/sms-numbers/#{sms_number_id}")
end

#get(sms_number_id:) ⇒ Object



30
31
32
# File 'lib/mailersend/sms_number/sms_number.rb', line 30

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

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



20
21
22
23
24
25
26
27
28
# File 'lib/mailersend/sms_number/sms_number.rb', line 20

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-numbers',
                                   query: URI.encode_www_form(hash)))
end

#update(sms_number_id:, paused: nil) ⇒ Object



34
35
36
37
38
39
# File 'lib/mailersend/sms_number/sms_number.rb', line 34

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