@@ -4,24 +4,24 @@ package analytics
44
55import (
66 context "context"
7- serversdkgo "github.com/VapiAI/server-sdk-go"
87 core "github.com/VapiAI/server-sdk-go/core"
8+ internal "github.com/VapiAI/server-sdk-go/internal"
99 option "github.com/VapiAI/server-sdk-go/option"
1010 http "net/http"
1111)
1212
1313type Client struct {
1414 baseURL string
15- caller * core .Caller
15+ caller * internal .Caller
1616 header http.Header
1717}
1818
1919func NewClient (opts ... option.RequestOption ) * Client {
2020 options := core .NewRequestOptions (opts ... )
2121 return & Client {
2222 baseURL : options .BaseURL ,
23- caller : core .NewCaller (
24- & core .CallerParams {
23+ caller : internal .NewCaller (
24+ & internal .CallerParams {
2525 Client : options .HTTPClient ,
2626 MaxAttempts : options .MaxAttempts ,
2727 },
@@ -32,39 +32,33 @@ func NewClient(opts ...option.RequestOption) *Client {
3232
3333func (c * Client ) Get (
3434 ctx context.Context ,
35- request * serversdkgo.AnalyticsQueryDto ,
3635 opts ... option.RequestOption ,
37- ) ([] * serversdkgo. AnalyticsQueryResult , error ) {
36+ ) error {
3837 options := core .NewRequestOptions (opts ... )
39-
40- baseURL := "https://api.vapi.ai"
41- if c .baseURL != "" {
42- baseURL = c .baseURL
43- }
44- if options .BaseURL != "" {
45- baseURL = options .BaseURL
46- }
38+ baseURL := internal .ResolveBaseURL (
39+ options .BaseURL ,
40+ c .baseURL ,
41+ "https://api.vapi.ai" ,
42+ )
4743 endpointURL := baseURL + "/analytics"
44+ headers := internal .MergeHeaders (
45+ c .header .Clone (),
46+ options .ToHeader (),
47+ )
4848
49- headers := core .MergeHeaders (c .header .Clone (), options .ToHeader ())
50- headers .Set ("Content-Type" , "application/json" )
51-
52- var response []* serversdkgo.AnalyticsQueryResult
5349 if err := c .caller .Call (
5450 ctx ,
55- & core .CallParams {
51+ & internal .CallParams {
5652 URL : endpointURL ,
5753 Method : http .MethodPost ,
58- MaxAttempts : options .MaxAttempts ,
5954 Headers : headers ,
55+ MaxAttempts : options .MaxAttempts ,
6056 BodyProperties : options .BodyProperties ,
6157 QueryParameters : options .QueryParameters ,
6258 Client : options .HTTPClient ,
63- Request : request ,
64- Response : & response ,
6559 },
6660 ); err != nil {
67- return nil , err
61+ return err
6862 }
69- return response , nil
63+ return nil
7064}
0 commit comments