Module: Mrkt::CrudHelpers

Included in:
Client
Defined in:
lib/mrkt/concerns/crud_helpers.rb

Instance Method Summary collapse

Instance Method Details

#json_payload(req, payload) ⇒ Object


14
15
16
17
# File 'lib/mrkt/concerns/crud_helpers.rb', line 14

def json_payload(req, payload)
  req.headers[:content_type] = 'application/json'
  req.body = JSON.generate(payload)
end

#map_lead_ids(lead_ids) ⇒ Object


3
4
5
# File 'lib/mrkt/concerns/crud_helpers.rb', line 3

def map_lead_ids(lead_ids)
  lead_ids.map { |id| { id: id } }
end

#post_json(url) ⇒ Object


7
8
9
10
11
12
# File 'lib/mrkt/concerns/crud_helpers.rb', line 7

def post_json(url)
  post(url) do |req|
    payload = block_given? ? yield(req) : {}
    json_payload(req, payload)
  end
end