Class: Smartsheet::Reports

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/smartsheet/endpoints/reports/reports.rb

Overview

Reports Endpoints

See Also:

Constant Summary

Constants included from Constants

Constants::API_URL, Constants::CSV_TYPE, Constants::DEFAULT_BACKOFF_METHOD, Constants::DEFAULT_MAX_RETRY_TIME, Constants::EXCEL_TYPE, Constants::GOV_API_URL, Constants::JSON_TYPE, Constants::OPENXML_SPREADSHEET_TYPE, Constants::PDF_TYPE, Constants::USER_AGENT, Constants::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Reports

Returns a new instance of Reports.



17
18
19
20
21
# File 'lib/smartsheet/endpoints/reports/reports.rb', line 17

def initialize(client)
  @client = client

  @share = ReportsShare.new(client)
end

Instance Attribute Details

#shareReportsShare (readonly)

Returns:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/smartsheet/endpoints/reports/reports.rb', line 11

class Reports
  include Smartsheet::Constants

  attr_reader :client, :share
  private :client

  def initialize(client)
    @client = client

    @share = ReportsShare.new(client)
  end

  def get(report_id:, params: {}, header_overrides: {})
    endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['reports', :report_id])
    request_spec = Smartsheet::API::RequestSpec.new(
        header_overrides: header_overrides,
        params: params,
        report_id: report_id
    )
    client.make_request(endpoint_spec, request_spec)
  end

  def get_as_excel(report_id:, params: {}, header_overrides: {})
    endpoint_spec = Smartsheet::API::EndpointSpec.new(
        :get,
        ['reports', :report_id],
        headers: {Accept: EXCEL_TYPE}
    )
    request_spec = Smartsheet::API::RequestSpec.new(
        header_overrides: header_overrides,
        params: params,
        report_id: report_id
    )
    client.make_request(endpoint_spec, request_spec)
  end

  def get_as_csv(report_id:, params: {}, header_overrides: {})
    endpoint_spec = Smartsheet::API::EndpointSpec.new(
        :get,
        ['reports', :report_id],
        headers: {Accept: CSV_TYPE})
    request_spec = Smartsheet::API::RequestSpec.new(
        header_overrides: header_overrides,
        params: params,
        report_id: report_id
    )
    client.make_request(endpoint_spec, request_spec)
  end

  def list(params: {}, header_overrides: {})
    endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['reports'])
    request_spec = Smartsheet::API::RequestSpec.new(
        header_overrides: header_overrides,
        params: params
    )
    client.make_request(endpoint_spec, request_spec)
  end

  def get_publish_status(report_id:, params: {}, header_overrides: {})
    endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['reports', :report_id, 'publish'])
    request_spec = Smartsheet::API::RequestSpec.new(
        params: params,
        header_overrides: header_overrides,
        report_id: report_id
    )
    client.make_request(endpoint_spec, request_spec)
  end

  def set_publish_status(report_id:, body:, params: {}, header_overrides: {})
    endpoint_spec = Smartsheet::API::EndpointSpec.new(:put, ['reports', :report_id, 'publish'], body_type: :json)
    request_spec = Smartsheet::API::RequestSpec.new(
        params: params,
        header_overrides: header_overrides,
        body: body,
        report_id: report_id
    )
    client.make_request(endpoint_spec, request_spec)
  end

  def send_via_email(report_id:, body:, params: {}, header_overrides: {})
    endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['reports', :report_id, 'emails'], body_type: :json)
    request_spec = Smartsheet::API::RequestSpec.new(
        params: params,
        header_overrides: header_overrides,
        body: body,
        report_id: report_id
    )
    client.make_request(endpoint_spec, request_spec)
  end
end

Instance Method Details

#get(report_id:, params: {}, header_overrides: {}) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/smartsheet/endpoints/reports/reports.rb', line 23

def get(report_id:, params: {}, header_overrides: {})
  endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['reports', :report_id])
  request_spec = Smartsheet::API::RequestSpec.new(
      header_overrides: header_overrides,
      params: params,
      report_id: report_id
  )
  client.make_request(endpoint_spec, request_spec)
end

#get_as_csv(report_id:, params: {}, header_overrides: {}) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/smartsheet/endpoints/reports/reports.rb', line 47

def get_as_csv(report_id:, params: {}, header_overrides: {})
  endpoint_spec = Smartsheet::API::EndpointSpec.new(
      :get,
      ['reports', :report_id],
      headers: {Accept: CSV_TYPE})
  request_spec = Smartsheet::API::RequestSpec.new(
      header_overrides: header_overrides,
      params: params,
      report_id: report_id
  )
  client.make_request(endpoint_spec, request_spec)
end

#get_as_excel(report_id:, params: {}, header_overrides: {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/smartsheet/endpoints/reports/reports.rb', line 33

def get_as_excel(report_id:, params: {}, header_overrides: {})
  endpoint_spec = Smartsheet::API::EndpointSpec.new(
      :get,
      ['reports', :report_id],
      headers: {Accept: EXCEL_TYPE}
  )
  request_spec = Smartsheet::API::RequestSpec.new(
      header_overrides: header_overrides,
      params: params,
      report_id: report_id
  )
  client.make_request(endpoint_spec, request_spec)
end

#get_publish_status(report_id:, params: {}, header_overrides: {}) ⇒ Object



69
70
71
72
73
74
75
76
77
# File 'lib/smartsheet/endpoints/reports/reports.rb', line 69

def get_publish_status(report_id:, params: {}, header_overrides: {})
  endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['reports', :report_id, 'publish'])
  request_spec = Smartsheet::API::RequestSpec.new(
      params: params,
      header_overrides: header_overrides,
      report_id: report_id
  )
  client.make_request(endpoint_spec, request_spec)
end

#list(params: {}, header_overrides: {}) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/smartsheet/endpoints/reports/reports.rb', line 60

def list(params: {}, header_overrides: {})
  endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['reports'])
  request_spec = Smartsheet::API::RequestSpec.new(
      header_overrides: header_overrides,
      params: params
  )
  client.make_request(endpoint_spec, request_spec)
end

#send_via_email(report_id:, body:, params: {}, header_overrides: {}) ⇒ Object



90
91
92
93
94
95
96
97
98
99
# File 'lib/smartsheet/endpoints/reports/reports.rb', line 90

def send_via_email(report_id:, body:, params: {}, header_overrides: {})
  endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['reports', :report_id, 'emails'], body_type: :json)
  request_spec = Smartsheet::API::RequestSpec.new(
      params: params,
      header_overrides: header_overrides,
      body: body,
      report_id: report_id
  )
  client.make_request(endpoint_spec, request_spec)
end

#set_publish_status(report_id:, body:, params: {}, header_overrides: {}) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/smartsheet/endpoints/reports/reports.rb', line 79

def set_publish_status(report_id:, body:, params: {}, header_overrides: {})
  endpoint_spec = Smartsheet::API::EndpointSpec.new(:put, ['reports', :report_id, 'publish'], body_type: :json)
  request_spec = Smartsheet::API::RequestSpec.new(
      params: params,
      header_overrides: header_overrides,
      body: body,
      report_id: report_id
  )
  client.make_request(endpoint_spec, request_spec)
end