Class: PersonaApi::InquiriesResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/persona_api/resources/inquiries.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#delete_request, #get_request, #handle_response, #initialize, #patch_request, #post_request, #put_request

Constructor Details

This class inherits a constructor from PersonaApi::Resource

Instance Method Details

#add_tag(inq_id:, **attributes) ⇒ Object



3
4
5
6
# File 'lib/persona_api/resources/inquiries.rb', line 3

def add_tag(inq_id:, **attributes)
  post_request("inquiries/#{inq_id}/add-tag", body: attributes)
  true
end

#approve(inq_id:, **attributes) ⇒ Object



8
9
10
# File 'lib/persona_api/resources/inquiries.rb', line 8

def approve(inq_id:, **attributes)
  post_request("inquiries/#{inq_id}/approve", body: attributes)
end

#create(**attributes) ⇒ Object



12
13
14
15
# File 'lib/persona_api/resources/inquiries.rb', line 12

def create(**attributes)
  # inquiry attributes must include one of 'template-id' or 'inquiry-template-id'
  Inquiry.new post_request("inquiries", body: attributes).body.dig("data")
end

#decline(inq_id:, **attributes) ⇒ Object



17
18
19
# File 'lib/persona_api/resources/inquiries.rb', line 17

def decline(inq_id:, **attributes)
  post_request("inquiries/#{inq_id}/decline", body: attributes)
end

#list(**params) ⇒ Object



21
22
23
# File 'lib/persona_api/resources/inquiries.rb', line 21

def list(**params)
  Collection.from_response get_request("inquiries", params: params), key: "data", type: Inquiry
end


25
26
27
28
# File 'lib/persona_api/resources/inquiries.rb', line 25

def print(inq_id:)
  get_request("inquiries/#{inq_id}/print")
  true
end

#redact(inq_id:) ⇒ Object



34
35
36
# File 'lib/persona_api/resources/inquiries.rb', line 34

def redact(inq_id:)
  delete_request("inquiries/#{inq_id}")
end

#remove_tag(inq_id:, **attributes) ⇒ Object



38
39
40
41
# File 'lib/persona_api/resources/inquiries.rb', line 38

def remove_tag(inq_id:, **attributes)
  post_request("inquiries/#{inq_id}/remove-tag", body: attributes)
  true
end

#resume(inq_id:, **attributes) ⇒ Object



43
44
45
46
# File 'lib/persona_api/resources/inquiries.rb', line 43

def resume(inq_id:, **attributes)
  # this request will return only the session_token
  post_request("inquiries/#{inq_id}/resume", body: attributes).body.dig("meta", "session_token")
end

#retrieve(inq_id:) ⇒ Object



30
31
32
# File 'lib/persona_api/resources/inquiries.rb', line 30

def retrieve(inq_id:)
  Inquiry.new get_request("inquiries/#{inq_id}").body.dig("data")
end

#set_all_tags(inq_id:, **attributes) ⇒ Object



48
49
50
51
# File 'lib/persona_api/resources/inquiries.rb', line 48

def set_all_tags(inq_id:, **attributes)
  post_request("inquiries/#{inq_id}/set-tags", body: attributes)
  true
end

#update(inq_id:, **attributes) ⇒ Object



53
54
55
# File 'lib/persona_api/resources/inquiries.rb', line 53

def update(inq_id:, **attributes)
  Inquiry.new patch_request("inquiries/#{inq_id}", body: attributes).body.dig("data")
end