Class: Userfox::Client
- Inherits:
-
Object
- Object
- Userfox::Client
- Includes:
- HTTParty
- Defined in:
- lib/userfox/client.rb
Instance Method Summary collapse
- #change(from, to, options = {}) ⇒ Object
-
#initialize(client_id, client_secret) ⇒ Client
constructor
A new instance of Client.
- #post(path, options = {}) ⇒ Object
- #send(email, name, delta = {}, options = {}) ⇒ Object
- #track(email, url, delta = {}, options = {}) ⇒ Object
- #unsubscribes(email, options = {}) ⇒ Object
Constructor Details
#initialize(client_id, client_secret) ⇒ Client
Returns a new instance of Client.
8 9 10 |
# File 'lib/userfox/client.rb', line 8 def initialize(client_id, client_secret) @auth = { username: client_id, password: client_secret } end |
Instance Method Details
#change(from, to, options = {}) ⇒ Object
29 30 31 32 33 |
# File 'lib/userfox/client.rb', line 29 def change(from, to, = {}) [:body] = { from: from, to: to } post("/change.json", ) end |
#post(path, options = {}) ⇒ Object
12 13 14 15 |
# File 'lib/userfox/client.rb', line 12 def post(path, = {}) .merge!({ basic_auth: @auth }) handle_response { self.class.post(path, ) } end |
#send(email, name, delta = {}, options = {}) ⇒ Object
23 24 25 26 27 |
# File 'lib/userfox/client.rb', line 23 def send(email, name, delta = {}, = {}) [:body] = { addr: email, name: name, delta: delta.to_json } post("/send.json", ) end |
#track(email, url, delta = {}, options = {}) ⇒ Object
17 18 19 20 21 |
# File 'lib/userfox/client.rb', line 17 def track(email, url, delta = {}, = {}) [:body] = { addr: email, url: url, delta: delta.to_json } post("/track.json", ) end |
#unsubscribes(email, options = {}) ⇒ Object
35 36 37 38 39 |
# File 'lib/userfox/client.rb', line 35 def unsubscribes(email, = {}) [:body] = { addr: email } post("/unsubscribes.json", ) end |