Class: Exponent::Push::Client
- Inherits:
-
Object
- Object
- Exponent::Push::Client
- Defined in:
- lib/exponent-server-sdk-jm.rb
Instance Method Summary collapse
-
#initialize(**args) ⇒ Client
constructor
A new instance of Client.
- #publish(messages) ⇒ Object deprecated Deprecated.
-
#send_messages(messages, **args) ⇒ Object
returns response handler that provides access to errors? and other response inspection methods.
- #verify_deliveries(receipt_ids, **args) ⇒ Object
Constructor Details
#initialize(**args) ⇒ Client
Returns a new instance of Client.
39 40 41 42 43 44 45 |
# File 'lib/exponent-server-sdk-jm.rb', line 39 def initialize(**args) @http_client = args[:http_client] || Typhoeus @error_builder = ErrorBuilder.new # future versions will deprecate this @response_handler = args[:response_handler] || ResponseHandler.new @gzip = args[:gzip] == true end |
Instance Method Details
#publish(messages) ⇒ Object
Deprecated.
returns a string response with parsed success json or error
49 50 51 52 |
# File 'lib/exponent-server-sdk-jm.rb', line 49 def publish() warn '[DEPRECATION] `publish` is deprecated. Please use `send_messages` instead.' @response_handler.handle(push_notifications()) end |
#send_messages(messages, **args) ⇒ Object
returns response handler that provides access to errors? and other response inspection methods
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/exponent-server-sdk-jm.rb', line 55 def (, **args) # https://docs.expo.io/versions/latest/guides/push-notifications/#message-format raise TooManyMessagesError, 'Only 100 message objects at a time allowed.' if .length > 100 response = push_notifications() # each call to send_messages will return a new instance of ResponseHandler handler = args[:response_handler] || ResponseHandler.new handler.process_response(response) handler end |
#verify_deliveries(receipt_ids, **args) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/exponent-server-sdk-jm.rb', line 67 def verify_deliveries(receipt_ids, **args) response = get_receipts(receipt_ids) handler = args[:response_handler] || ResponseHandler.new handler.process_response(response) handler end |