-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics.go
More file actions
87 lines (68 loc) · 2.16 KB
/
Copy pathanalytics.go
File metadata and controls
87 lines (68 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
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
package fastbi
import (
"context"
"net/http"
)
type RevenueInsightsFilter struct {
StartDate string
EndDate string
Category string
Region string
}
type ExpansionOpportunitiesRequest struct {
MinRevenueThreshold float64 `json:"min_revenue_threshold"`
}
type ProductMixRequest struct {
OrganizationName string `json:"organization_name"`
StartDate *string `json:"start_date,omitempty"`
EndDate *string `json:"end_date,omitempty"`
}
type ForecastRequest struct {
OrganizationName string `json:"organization_name"`
MonthsAhead int `json:"months_ahead"`
IncludeExternalFactors bool `json:"include_external_factors"`
}
type AnalyticsService struct{ c *Client }
func (s *AnalyticsService) RevenueInsights(ctx context.Context, f *RevenueInsightsFilter) (map[string]any, error) {
params := []string{}
if f != nil {
if f.StartDate != "" {
params = append(params, "start_date", f.StartDate)
}
if f.EndDate != "" {
params = append(params, "end_date", f.EndDate)
}
if f.Category != "" {
params = append(params, "category", f.Category)
}
if f.Region != "" {
params = append(params, "region", f.Region)
}
}
var out map[string]any
if err := s.c.do(ctx, http.MethodGet, s.c.url("/analytics/revenue-insights", params...), nil, &out); err != nil {
return nil, err
}
return out, nil
}
func (s *AnalyticsService) ExpansionOpportunities(ctx context.Context, req *ExpansionOpportunitiesRequest) (map[string]any, error) {
var out map[string]any
if err := s.c.do(ctx, http.MethodGet, "/analytics/expansion-opportunities", req, &out); err != nil {
return nil, err
}
return out, nil
}
func (s *AnalyticsService) OptimizeProductMix(ctx context.Context, req *ProductMixRequest) (map[string]any, error) {
var out map[string]any
if err := s.c.do(ctx, http.MethodPost, "/analytics/product-mix", req, &out); err != nil {
return nil, err
}
return out, nil
}
func (s *AnalyticsService) ForecastRevenue(ctx context.Context, req *ForecastRequest) (map[string]any, error) {
var out map[string]any
if err := s.c.do(ctx, http.MethodPost, "/analytics/forecast", req, &out); err != nil {
return nil, err
}
return out, nil
}