Sha256: 5a66fbf3b1a5034dab28e0fe181e903abf7ecc593b6e1ff807674ccec8747789

Contents?: true

Size: 739 Bytes

Versions: 1

Compression:

Stored size: 739 Bytes

Contents

module AwsSnsManager
  # = AwsSnsManager::Client
  class Client
    attr_accessor :client
    attr_accessor :arn

    def initialize(options = {})
      super()

      @client = Aws::SNS::Client.new(options)
    end

    def send
      message = message('Hi').to_json
      response = publish_rescue(message)
      !response.nil?
    end

    def publish_rescue(message)
      client.publish(
        target_arn: arn,
        message: message,
        message_structure: 'json'
      )
    end

    def message(text)
      {
        APNS: notification(text).to_json
      }
    end

    def notification(text)
      {
        aps: {
          alert: text,
          sound: 'default',
          badge: 1
        }
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aws_sns_manager-0.0.1 lib/aws_sns_manager/client.rb