Skip to content

Commit

Permalink
customer-api: remove moved methods and methods not requiring authenti…
Browse files Browse the repository at this point in the history
…cation
  • Loading branch information
wfabjanczuk committed Jan 16, 2025
1 parent 042dcfe commit 3234c23
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 232 deletions.
54 changes: 0 additions & 54 deletions customer/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,27 +352,6 @@ func (a *API) GetCustomer() (*Customer, error) {
return &resp, err
}

// ListLicenseProperties returns the properties of a given license.
func (a *API) ListLicenseProperties(namespace, name string) (Properties, error) {
var resp Properties
err := a.Call("list_license_properties", &listLicensePropertiesRequest{
Namespace: namespace,
Name: name,
}, &resp, &i.CallOptions{Method: http.MethodGet})
return resp, err
}

// ListGroupProperties returns the properties of a given group.
func (a *API) ListGroupProperties(groupID uint, namespace, name string) (Properties, error) {
var resp Properties
err := a.Call("list_group_properties", &listGroupPropertiesRequest{
ID: groupID,
Namespace: namespace,
Name: name,
}, &resp, &i.CallOptions{Method: http.MethodGet})
return resp, err
}

// AcceptGreeting marks an incoming greeting as seen.
func (a *API) AcceptGreeting(greetingID int, uniqueID string) error {
return a.Call("accept_greeting", &acceptGreetingRequest{
Expand All @@ -394,36 +373,3 @@ func (a *API) RequestEmailVerification(callbackURI string) error {
CallbackURI: callbackURI,
}, &emptyResponse{})
}

// GetDynamicConfiguration returns the dynamic configuration of a given group. It provides data to call Get Configuration and Get Localization.
func (a *API) GetDynamicConfiguration(groupID int, url, channelType string, isTest bool) (*DynamicConfiguration, error) {
var resp DynamicConfiguration
err := a.Call("get_dynamic_configuration", &getDynamicConfigurationRequest{
GroupID: groupID,
URL: url,
ChannelType: channelType,
Test: isTest,
}, &resp, &i.CallOptions{Method: http.MethodGet})
return &resp, err
}

// GetConfiguration returns the configuration of a given group in a given version.
func (a *API) GetConfiguration(groupID int, version string) (*Configuration, error) {
var resp Configuration
err := a.Call("get_configuration", &getConfigurationRequest{
GroupID: groupID,
Version: version,
}, &resp, &i.CallOptions{Method: http.MethodGet})
return &resp, err
}

// GetLocalization returns the localization of a given language and group in a given version.
func (a *API) GetLocalization(groupID int, language, version string) (map[string]string, error) {
var resp map[string]string
err := a.Call("get_localization", &getLocalizationRequest{
GroupID: groupID,
Language: language,
Version: version,
}, &resp, &i.CallOptions{Method: http.MethodGet})
return resp, err
}
138 changes: 0 additions & 138 deletions customer/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1288,50 +1288,6 @@ func TestGetCustomerShouldNotCrashOnErrorResponse(t *testing.T) {
verifyErrorResponse("GetCustomer", rErr, t)
}

func TestListLicensePropertiesShouldReturnDataReceivedFromCustomerAPI(t *testing.T) {
client := NewTestClient(createMockedResponder(t, "list_license_properties"))

api, err := customer.NewAPI(stubTokenGetter, client, "client_id")
if err != nil {
t.Error("API creation failed")
}

resp, rErr := api.ListLicenseProperties("", "")
if rErr != nil {
t.Errorf("ListLicenseProperties failed: %v", rErr)
}

if len(resp) != 1 {
t.Errorf("Invalid license properties: %v", resp)
}

if resp["0805e283233042b37f460ed8fbf22160"]["string_property"] != "string value" {
t.Errorf("Invalid license property 0805e283233042b37f460ed8fbf22160.string_property: %v", resp["0805e283233042b37f460ed8fbf22160"]["string_property"])
}
}

func TestListGroupPropertiesShouldReturnDataReceivedFromCustomerAPI(t *testing.T) {
client := NewTestClient(createMockedResponder(t, "list_group_properties"))

api, err := customer.NewAPI(stubTokenGetter, client, "client_id")
if err != nil {
t.Error("API creation failed")
}

resp, rErr := api.ListGroupProperties(0, "", "")
if rErr != nil {
t.Errorf("ListGroupProperties failed: %v", rErr)
}

if len(resp) != 1 {
t.Errorf("Invalid group properties: %v", resp)
}

if resp["0805e283233042b37f460ed8fbf22160"]["string_property"] != "string value" {
t.Errorf("Invalid group property 0805e283233042b37f460ed8fbf22160.string_property: %v", resp["0805e283233042b37f460ed8fbf22160"]["string_property"])
}
}

func TestAcceptGreetingShouldReturnDataReceivedFromCustomerAPI(t *testing.T) {
client := NewTestClient(createMockedResponder(t, "accept_greeting"))

Expand Down Expand Up @@ -1382,97 +1338,3 @@ func TestCancelGreetingShouldNotCrashOnErrorResponse(t *testing.T) {
rErr := api.CancelGreeting("foo")
verifyErrorResponse("CancelGreeting", rErr, t)
}

func TestGetDynamicConfigurationShouldReturnDataReceivedFromCustomerAPI(t *testing.T) {
client := NewTestClient(createMockedResponder(t, "get_dynamic_configuration"))

api, err := customer.NewAPI(stubTokenGetter, client, "client_id")
if err != nil {
t.Error("API creation failed")
}

resp, rErr := api.GetDynamicConfiguration(0, "foo", "bar", false)
if rErr != nil {
t.Errorf("GetDynamicConfiguration failed: %v", rErr)
}

if resp.ClientLimitExceeded {
t.Errorf("Invalid client_limit_exceeded: %v", resp.ClientLimitExceeded)
}

if resp.GroupID != 0 {
t.Errorf("Invalid group_id: %v", resp.GroupID)
}

if !resp.DomainAllowed {
t.Errorf("Invalid domain_allowed: %v", resp.DomainAllowed)
}

if resp.ConfigVersion != "84cc87cxza5ee24ed0f84fe3027fjf0c71" {
t.Errorf("Invalid config_version: %v", resp.ConfigVersion)
}

if resp.LocalizationVersion != "79cc87cea5ee24ed0f84fe3027fc0c74" {
t.Errorf("Invalid localization_version: %v", resp.LocalizationVersion)
}

if resp.Language != "en" {
t.Errorf("Invalid language: %v", resp.Language)
}
}

func TestGetConfigurationShouldReturnDataReceivedFromCustomerAPI(t *testing.T) {
client := NewTestClient(createMockedResponder(t, "get_configuration"))

api, err := customer.NewAPI(stubTokenGetter, client, "client_id")
if err != nil {
t.Error("API creation failed")
}

resp, rErr := api.GetConfiguration(0, "foo")
if rErr != nil {
t.Errorf("GetConfiguration failed: %v", rErr)
}

if len(resp.Buttons) != 3 {
t.Errorf("Invalid buttons: %v", resp.Buttons)
}

if len(resp.TicketForm.Fields) != 1 {
t.Errorf("Invalid ticket_form.fields: %v", resp.TicketForm.Fields)
}

if resp.TicketForm.ID != "ticket_form_id" {
t.Errorf("Invalid ticket_form.id: %v", resp.TicketForm.ID)
}

if len(resp.PrechatForm.Fields) != 1 {
t.Errorf("Invalid prechat_form.fields: %v", resp.PrechatForm.Fields)
}

if resp.PrechatForm.ID != "prechat_form_id" {
t.Errorf("Invalid prechat_form.id: %v", resp.PrechatForm.ID)
}
}

func TestGetLocalizationShouldReturnDataReceivedFromCustomerAPI(t *testing.T) {
client := NewTestClient(createMockedResponder(t, "get_localization"))

api, err := customer.NewAPI(stubTokenGetter, client, "client_id")
if err != nil {
t.Error("API creation failed")
}

resp, rErr := api.GetLocalization(0, "foo", "bar")
if rErr != nil {
t.Errorf("GetLocalization failed: %v", rErr)
}

if len(resp) != 1 {
t.Errorf("Invalid response size: %v", resp)
}

if resp["Agents_currently_not_available"] != "Our agents are not available at the moment." {
t.Errorf("Invalid response content: %v", resp)
}
}
18 changes: 0 additions & 18 deletions customer/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,3 @@ type hashedPaginationResponse struct {
type requestEmailVerificationRequest struct {
CallbackURI string `json:"callback_uri"`
}

type getDynamicConfigurationRequest struct {
GroupID int `url:"group_id"`
URL string `url:"url"`
ChannelType string `url:"channel_type"`
Test bool `url:"test"`
}

type getConfigurationRequest struct {
GroupID int `url:"group_id"`
Version string `url:"version"`
}

type getLocalizationRequest struct {
GroupID int `url:"group_id"`
Language string `url:"language"`
Version string `url:"version"`
}
22 changes: 0 additions & 22 deletions customer/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,35 +51,13 @@ type URLInfo struct {
ImageHeight int `json:"image_height"`
}

type DynamicConfiguration struct {
GroupID int `json:"group_id"`
OrganizationID string `json:"organization_id"`
ClientLimitExceeded bool `json:"client_limit_exceeded"`
DomainAllowed bool `json:"domain_allowed"`
ConfigVersion string `json:"config_version"`
LocalizationVersion string `json:"localization_version"`
Language string `json:"language"`
}

type ConfigButton struct {
ID string `json:"id"`
Type string `json:"type"`
OnlineValue string `json:"online_value"`
OfflineValue string `json:"offline_value"`
}

type Configuration struct {
Buttons []ConfigButton `json:"buttons"`
TicketForm *Form `json:"ticket_form,omitempty"`
PrechatForm *Form `json:"prechat_form,omitempty"`
AllowedDomains []string `json:"allowed_domains,omitempty"`
Integrations map[string]map[string]string `json:"integrations"`
Properties struct {
Group Properties `json:"group"`
License Properties `json:"license"`
} `json:"properties"`
}

// User represents base of both Customer and Agent
//
// To get specific user type's structure, call Agent() or Customer() (based on Type value).
Expand Down

0 comments on commit 3234c23

Please sign in to comment.