Class: ShelfWatch::Resources::Visits

Inherits:
Object
  • Object
show all
Defined in:
lib/shelfwatch/resources/visits.rb

Overview

Visit list and detail endpoints.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Visits

Returns a new instance of Visits.



7
8
9
# File 'lib/shelfwatch/resources/visits.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#get(visit_uuid, project_id: nil, include_kpis: false, kpi_level: "topline", template_id: nil, category: nil) ⇒ Object

Get visit details (images, survey; optionally KPIs or a template).



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/shelfwatch/resources/visits.rb', line 45

def get(
  visit_uuid,
  project_id: nil,
  include_kpis: false,
  kpi_level: "topline",
  template_id: nil,
  category: nil
)
  @client.request(
    "GET",
    "/v2/visits/#{visit_uuid}",
    params: Http.drop_none(
      project_id: @client.project(project_id),
      include_kpis: include_kpis,
      kpi_level: kpi_level,
      template_id: template_id,
      category: category
    )
  )
end

#list(start_date:, end_date:, project_id: nil, limit: 100, offset: 0, user_uuid: nil, store_code: nil, visit_status: nil, has_images: nil, has_survey: nil, include_total: true) ⇒ Object

List visits for a project (max 31-day range).



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
# File 'lib/shelfwatch/resources/visits.rb', line 12

def list(
  start_date:,
  end_date:,
  project_id: nil,
  limit: 100,
  offset: 0,
  user_uuid: nil,
  store_code: nil,
  visit_status: nil,
  has_images: nil,
  has_survey: nil,
  include_total: true
)
  @client.request(
    "GET",
    "/v2/visits",
    params: Http.drop_none(
      project_id: @client.project(project_id),
      start_date: Http.format_date(start_date),
      end_date: Http.format_date(end_date),
      limit: limit,
      offset: offset,
      user_uuid: Http.join_csv(user_uuid),
      store_code: Http.join_csv(store_code),
      visit_status: Http.join_csv(visit_status),
      has_images: has_images,
      has_survey: has_survey,
      include_total: include_total
    )
  )
end