Sha256: cd04321b2abe0a09e4f09ed0f5cb6dfa82f7d17f51e83a01d7b6b2668ae782f9

Contents?: true

Size: 1.09 KB

Versions: 11

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Mailersend
  # SMS Recipient endpoint from MailerSend API.
  class SMSRecipient
    attr_accessor :client,
                  :status,
                  :sms_number_id,
                  :sms_recipient_id,
                  :page,
                  :limit

    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

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

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

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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mailersend-ruby-2.0.1 lib/mailersend/sms_recipient/sms_recipient.rb
mailersend-ruby-2.0.0 lib/mailersend/sms_recipient/sms_recipient.rb
mailersend-ruby-1.6.0 lib/mailersend/sms_recipient/sms_recipient.rb
mailersend-ruby-1.5.2 lib/mailersend/sms_recipient/sms_recipient.rb
mailersend-ruby-1.5.1 lib/mailersend/sms_recipient/sms_recipient.rb
mailersend-ruby-1.5.0 lib/mailersend/sms_recipient/sms_recipient.rb
mailersend-ruby-1.4.0 lib/mailersend/sms_recipient/sms_recipient.rb
mailersend-ruby-1.3.2 lib/mailersend/sms_recipient/sms_recipient.rb
mailersend-ruby-1.3.1 lib/mailersend/sms_recipient/sms_recipient.rb
mailersend-ruby-1.3.0 lib/mailersend/sms_recipient/sms_recipient.rb
mailersend-ruby-1.2.0 lib/mailersend/sms_recipient/sms_recipient.rb