Class: Marketing::OptIn

Inherits:
Object
  • Object
show all
Defined in:
lib/opt_in.rb

Constant Summary collapse

API_URL =
'http://localhost:9292/api/v1/marketings_opt_in'

Class Method Summary collapse

Class Method Details

.allObject



9
10
11
12
# File 'lib/opt_in.rb', line 9

def all
  response = HTTParty.get(API_URL)
  JSON.parse(response.body)
end

.create(params) ⇒ Object



19
20
21
22
23
# File 'lib/opt_in.rb', line 19

def create(params)
  http_params = params.to_query
  response = HTTParty.post("#{API_URL}?#{http_params}")
  response.code
end

.destroy(id) ⇒ Object



31
32
33
34
# File 'lib/opt_in.rb', line 31

def destroy(id)
  response = HTTParty.delete("#{API_URL}/#{id}")
  response.code
end

.find(id) ⇒ Object



14
15
16
17
# File 'lib/opt_in.rb', line 14

def find(id)
  response = HTTParty.get("#{API_URL}/#{id}")
  JSON.parse(response.body)
end

.update(id, params) ⇒ Object



25
26
27
28
29
# File 'lib/opt_in.rb', line 25

def update(id,params)
  http_params = params.to_query
  response = HTTParty.put("#{API_URL}/#{id}?#{http_params}")
  JSON.parse(response.body)
end