Class: PersonaApi::ReportsResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/persona_api/resources/reports.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(rep_id:, **attributes) ⇒ Object



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

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

#create(**attributes) ⇒ Object



8
9
10
11
12
13
# File 'lib/persona_api/resources/reports.rb', line 8

def create(**attributes)
  # report attributes must include a 'report-template-id' as well as other fields as laid out
  # in the documentation https://docs.withpersona.com/reference/supported-report-types-and-examples

  Report.new post_request("reports", body: attributes).body.dig("data")
end

#list(**params) ⇒ Object



15
16
17
# File 'lib/persona_api/resources/reports.rb', line 15

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


19
20
21
22
# File 'lib/persona_api/resources/reports.rb', line 19

def print(rep_id:)
  get_request("reports/#{rep_id}/print")
  true
end

#redact(rep_id:) ⇒ Object



28
29
30
# File 'lib/persona_api/resources/reports.rb', line 28

def redact(rep_id:)
  delete_request("reports/#{rep_id}")
end

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



32
33
34
35
# File 'lib/persona_api/resources/reports.rb', line 32

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

#retrieve(rep_id:) ⇒ Object



24
25
26
# File 'lib/persona_api/resources/reports.rb', line 24

def retrieve(rep_id:)
  Report.new get_request("reports/#{rep_id}").body.dig("data")
end

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



37
38
39
40
# File 'lib/persona_api/resources/reports.rb', line 37

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