Class: Andpush::Client
- Inherits:
-
Object
- Object
- Andpush::Client
- Defined in:
- lib/andpush/client.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#proxy_addr ⇒ Object
readonly
Returns the value of attribute proxy_addr.
-
#proxy_password ⇒ Object
readonly
Returns the value of attribute proxy_password.
-
#proxy_port ⇒ Object
readonly
Returns the value of attribute proxy_port.
-
#proxy_user ⇒ Object
readonly
Returns the value of attribute proxy_user.
-
#request_handler ⇒ Object
readonly
Returns the value of attribute request_handler.
Instance Method Summary collapse
-
#initialize(domain, proxy_addr: nil, proxy_port: nil, proxy_user: nil, proxy_password: nil, request_handler: RequestHandler.new, **options) ⇒ Client
constructor
A new instance of Client.
- #push(body, query: {}, headers: {}, **options) ⇒ Object
- #register_interceptor(interceptor) ⇒ Object
- #register_observer(observer) ⇒ Object
Constructor Details
#initialize(domain, proxy_addr: nil, proxy_port: nil, proxy_user: nil, proxy_password: nil, request_handler: RequestHandler.new, **options) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/andpush/client.rb', line 10 def initialize(domain, proxy_addr: nil, proxy_port: nil, proxy_user: nil, proxy_password: nil, request_handler: RequestHandler.new, **) @domain = domain @proxy_addr = proxy_addr @proxy_port = proxy_port @proxy_user = proxy_user @proxy_password = proxy_password @interceptors = [] @observers = [] @request_handler = request_handler @options = DEFAULT_OPTIONS.merge() register_interceptor(JsonSerializer.new) register_observer(ResponseHandler.new) register_observer(JsonDeserializer.new) end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
8 9 10 |
# File 'lib/andpush/client.rb', line 8 def domain @domain end |
#proxy_addr ⇒ Object (readonly)
Returns the value of attribute proxy_addr.
8 9 10 |
# File 'lib/andpush/client.rb', line 8 def proxy_addr @proxy_addr end |
#proxy_password ⇒ Object (readonly)
Returns the value of attribute proxy_password.
8 9 10 |
# File 'lib/andpush/client.rb', line 8 def proxy_password @proxy_password end |
#proxy_port ⇒ Object (readonly)
Returns the value of attribute proxy_port.
8 9 10 |
# File 'lib/andpush/client.rb', line 8 def proxy_port @proxy_port end |
#proxy_user ⇒ Object (readonly)
Returns the value of attribute proxy_user.
8 9 10 |
# File 'lib/andpush/client.rb', line 8 def proxy_user @proxy_user end |
#request_handler ⇒ Object (readonly)
Returns the value of attribute request_handler.
8 9 10 |
# File 'lib/andpush/client.rb', line 8 def request_handler @request_handler end |
Instance Method Details
#push(body, query: {}, headers: {}, **options) ⇒ Object
36 37 38 |
# File 'lib/andpush/client.rb', line 36 def push(body, query: {}, headers: {}, **) request(Net::HTTP::Post, uri('/fcm/send', query), body, headers, method: :push, **) end |
#register_interceptor(interceptor) ⇒ Object
26 27 28 29 |
# File 'lib/andpush/client.rb', line 26 def register_interceptor(interceptor) @interceptors << interceptor self end |
#register_observer(observer) ⇒ Object
31 32 33 34 |
# File 'lib/andpush/client.rb', line 31 def register_observer(observer) @observers << observer self end |