-
Notifications
You must be signed in to change notification settings - Fork 4
/
company_settings_service.go
62 lines (54 loc) · 3.07 KB
/
company_settings_service.go
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
package moysklad
import (
"context"
"fmt"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
)
// ContextCompanySettingsService
// Сервис для работы с настройками компании.
type ContextCompanySettingsService struct {
Endpoint
endpointGetOne[CompanySettings]
endpointUpdate[CompanySettings]
endpointMetadata[MetadataCompanySettings]
}
func NewContextCompanySettingsService(client *Client) *ContextCompanySettingsService {
e := NewEndpoint(client, "context/companysettings")
return &ContextCompanySettingsService{
Endpoint: e,
endpointGetOne: endpointGetOne[CompanySettings]{e},
endpointUpdate: endpointUpdate[CompanySettings]{e},
endpointMetadata: endpointMetadata[MetadataCompanySettings]{e},
}
}
// GetPriceTypes Получить список всех типов цен.
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-tipy-cen-poluchit-spisok-wseh-tipow-cen
func (s *ContextCompanySettingsService) GetPriceTypes(ctx context.Context) (*[]PriceType, *resty.Response, error) {
path := "context/companysettings/pricetype"
return NewRequestBuilder[[]PriceType](s.client, path).Get(ctx)
}
// CreatePriceType Создать тип цен.
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-tipy-cen-redaktirowanie-spiska-tipow-cen
func (s *ContextCompanySettingsService) CreatePriceType(ctx context.Context, priceType *PriceType) (*[]PriceType, *resty.Response, error) {
path := "context/companysettings/pricetype"
return NewRequestBuilder[[]PriceType](s.client, path).Post(ctx, priceType)
}
// UpdatePriceTypes Редактирование списка типов цен.
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-tipy-cen-redaktirowanie-spiska-tipow-cen
func (s *ContextCompanySettingsService) UpdatePriceTypes(ctx context.Context, priceTypes []*PriceType) (*[]PriceType, *resty.Response, error) {
path := "context/companysettings/pricetype"
return NewRequestBuilder[[]PriceType](s.client, path).Post(ctx, priceTypes)
}
// GetPriceTypeById Получить тип цены по ID.
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-tipy-cen-poluchit-tip-ceny-po-id
func (s *ContextCompanySettingsService) GetPriceTypeById(ctx context.Context, id *uuid.UUID) (*PriceType, *resty.Response, error) {
path := fmt.Sprintf("context/companysettings/pricetype/%s", id)
return NewRequestBuilder[PriceType](s.client, path).Get(ctx)
}
// GetPriceTypeDefault Получить тип цены по умолчанию.
// Документация МойСклад: https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-tipy-cen-poluchit-tip-ceny-po-umolchaniu
func (s *ContextCompanySettingsService) GetPriceTypeDefault(ctx context.Context) (*PriceType, *resty.Response, error) {
path := "context/companysettings/pricetype/default"
return NewRequestBuilder[PriceType](s.client, path).Get(ctx)
}