Skip to content

Commit c4d9c60

Browse files
Address typing issue with CRM and Ticketing RemoteField POST (#5)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent 093797c commit c4d9c60

File tree

4 files changed

+133
-19
lines changed

4 files changed

+133
-19
lines changed

client/client.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import (
1414
)
1515

1616
type Client interface {
17-
Ats() atsclient.Client
1817
Crm() crmclient.Client
19-
Filestorage() filestorageclient.Client
2018
Hris() hrisclient.Client
19+
Ats() atsclient.Client
2120
Ticketing() ticketingclient.Client
21+
Filestorage() filestorageclient.Client
2222
Accounting() accountingclient.Client
2323
}
2424

@@ -31,11 +31,11 @@ func NewClient(opts ...core.ClientOption) Client {
3131
baseURL: options.BaseURL,
3232
httpClient: options.HTTPClient,
3333
header: options.ToHeader(),
34-
atsClient: atsclient.NewClient(opts...),
3534
crmClient: crmclient.NewClient(opts...),
36-
filestorageClient: filestorageclient.NewClient(opts...),
3735
hrisClient: hrisclient.NewClient(opts...),
36+
atsClient: atsclient.NewClient(opts...),
3837
ticketingClient: ticketingclient.NewClient(opts...),
38+
filestorageClient: filestorageclient.NewClient(opts...),
3939
accountingClient: accountingclient.NewClient(opts...),
4040
}
4141
}
@@ -44,34 +44,34 @@ type client struct {
4444
baseURL string
4545
httpClient core.HTTPClient
4646
header http.Header
47-
atsClient atsclient.Client
4847
crmClient crmclient.Client
49-
filestorageClient filestorageclient.Client
5048
hrisClient hrisclient.Client
49+
atsClient atsclient.Client
5150
ticketingClient ticketingclient.Client
51+
filestorageClient filestorageclient.Client
5252
accountingClient accountingclient.Client
5353
}
5454

55-
func (c *client) Ats() atsclient.Client {
56-
return c.atsClient
57-
}
58-
5955
func (c *client) Crm() crmclient.Client {
6056
return c.crmClient
6157
}
6258

63-
func (c *client) Filestorage() filestorageclient.Client {
64-
return c.filestorageClient
65-
}
66-
6759
func (c *client) Hris() hrisclient.Client {
6860
return c.hrisClient
6961
}
7062

63+
func (c *client) Ats() atsclient.Client {
64+
return c.atsClient
65+
}
66+
7167
func (c *client) Ticketing() ticketingclient.Client {
7268
return c.ticketingClient
7369
}
7470

71+
func (c *client) Filestorage() filestorageclient.Client {
72+
return c.filestorageClient
73+
}
74+
7575
func (c *client) Accounting() accountingclient.Client {
7676
return c.accountingClient
7777
}

core/client_option.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ func (c *ClientOptions) cloneHeader() http.Header {
4848
headers := c.HTTPHeader.Clone()
4949
headers.Set("X-Fern-Language", "Go")
5050
headers.Set("X-Fern-SDK-Name", "github.com/merge-api/merge-go-client")
51-
headers.Set("X-Fern-SDK-Version", "0.1.2")
51+
headers.Set("X-Fern-SDK-Version", "0.1.3")
5252
return headers
5353
}

crm/types.go

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8823,8 +8823,8 @@ type RemoteData struct {
88238823
}
88248824

88258825
type RemoteField struct {
8826-
RemoteFieldClass *RemoteFieldClass `json:"remote_field_class,omitempty"`
8827-
Value map[string]any `json:"value,omitempty"`
8826+
RemoteFieldClass *RemoteFieldRemoteFieldClass `json:"remote_field_class,omitempty"`
8827+
Value *any `json:"value,omitempty"`
88288828
}
88298829

88308830
type RemoteFieldClass struct {
@@ -9097,6 +9097,63 @@ type RemoteFieldClassForCustomObjectClassItemSchema struct {
90979097
ItemChoices []*string `json:"item_choices,omitempty"`
90989098
}
90999099

9100+
type RemoteFieldRemoteFieldClass struct {
9101+
typeName string
9102+
String string
9103+
RemoteFieldClass *RemoteFieldClass
9104+
}
9105+
9106+
func NewRemoteFieldRemoteFieldClassFromString(value string) *RemoteFieldRemoteFieldClass {
9107+
return &RemoteFieldRemoteFieldClass{typeName: "string", String: value}
9108+
}
9109+
9110+
func NewRemoteFieldRemoteFieldClassFromRemoteFieldClass(value *RemoteFieldClass) *RemoteFieldRemoteFieldClass {
9111+
return &RemoteFieldRemoteFieldClass{typeName: "remoteFieldClass", RemoteFieldClass: value}
9112+
}
9113+
9114+
func (r *RemoteFieldRemoteFieldClass) UnmarshalJSON(data []byte) error {
9115+
var valueString string
9116+
if err := json.Unmarshal(data, &valueString); err == nil {
9117+
r.typeName = "string"
9118+
r.String = valueString
9119+
return nil
9120+
}
9121+
valueRemoteFieldClass := new(RemoteFieldClass)
9122+
if err := json.Unmarshal(data, &valueRemoteFieldClass); err == nil {
9123+
r.typeName = "remoteFieldClass"
9124+
r.RemoteFieldClass = valueRemoteFieldClass
9125+
return nil
9126+
}
9127+
return fmt.Errorf("%s cannot be deserialized as a %T", data, r)
9128+
}
9129+
9130+
func (r RemoteFieldRemoteFieldClass) MarshalJSON() ([]byte, error) {
9131+
switch r.typeName {
9132+
default:
9133+
return nil, fmt.Errorf("invalid type %s in %T", r.typeName, r)
9134+
case "string":
9135+
return json.Marshal(r.String)
9136+
case "remoteFieldClass":
9137+
return json.Marshal(r.RemoteFieldClass)
9138+
}
9139+
}
9140+
9141+
type RemoteFieldRemoteFieldClassVisitor interface {
9142+
VisitString(string) error
9143+
VisitRemoteFieldClass(*RemoteFieldClass) error
9144+
}
9145+
9146+
func (r *RemoteFieldRemoteFieldClass) Accept(visitor RemoteFieldRemoteFieldClassVisitor) error {
9147+
switch r.typeName {
9148+
default:
9149+
return fmt.Errorf("invalid type %s in %T", r.typeName, r)
9150+
case "string":
9151+
return visitor.VisitString(r.String)
9152+
case "remoteFieldClass":
9153+
return visitor.VisitRemoteFieldClass(r.RemoteFieldClass)
9154+
}
9155+
}
9156+
91009157
type RemoteFieldRequest struct {
91019158
RemoteFieldClass *RemoteFieldRequestRemoteFieldClass `json:"remote_field_class,omitempty"`
91029159
Value map[string]any `json:"value,omitempty"`

ticketing/types.go

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2921,8 +2921,8 @@ type RemoteData struct {
29212921
}
29222922

29232923
type RemoteField struct {
2924-
RemoteFieldClass *RemoteFieldClass `json:"remote_field_class,omitempty"`
2925-
Value map[string]any `json:"value,omitempty"`
2924+
RemoteFieldClass *RemoteFieldRemoteFieldClass `json:"remote_field_class,omitempty"`
2925+
Value *any `json:"value,omitempty"`
29262926
}
29272927

29282928
type RemoteFieldClass struct {
@@ -3057,6 +3057,63 @@ func (r *RemoteFieldClassFieldType) Accept(visitor RemoteFieldClassFieldTypeVisi
30573057
}
30583058
}
30593059

3060+
type RemoteFieldRemoteFieldClass struct {
3061+
typeName string
3062+
String string
3063+
RemoteFieldClass *RemoteFieldClass
3064+
}
3065+
3066+
func NewRemoteFieldRemoteFieldClassFromString(value string) *RemoteFieldRemoteFieldClass {
3067+
return &RemoteFieldRemoteFieldClass{typeName: "string", String: value}
3068+
}
3069+
3070+
func NewRemoteFieldRemoteFieldClassFromRemoteFieldClass(value *RemoteFieldClass) *RemoteFieldRemoteFieldClass {
3071+
return &RemoteFieldRemoteFieldClass{typeName: "remoteFieldClass", RemoteFieldClass: value}
3072+
}
3073+
3074+
func (r *RemoteFieldRemoteFieldClass) UnmarshalJSON(data []byte) error {
3075+
var valueString string
3076+
if err := json.Unmarshal(data, &valueString); err == nil {
3077+
r.typeName = "string"
3078+
r.String = valueString
3079+
return nil
3080+
}
3081+
valueRemoteFieldClass := new(RemoteFieldClass)
3082+
if err := json.Unmarshal(data, &valueRemoteFieldClass); err == nil {
3083+
r.typeName = "remoteFieldClass"
3084+
r.RemoteFieldClass = valueRemoteFieldClass
3085+
return nil
3086+
}
3087+
return fmt.Errorf("%s cannot be deserialized as a %T", data, r)
3088+
}
3089+
3090+
func (r RemoteFieldRemoteFieldClass) MarshalJSON() ([]byte, error) {
3091+
switch r.typeName {
3092+
default:
3093+
return nil, fmt.Errorf("invalid type %s in %T", r.typeName, r)
3094+
case "string":
3095+
return json.Marshal(r.String)
3096+
case "remoteFieldClass":
3097+
return json.Marshal(r.RemoteFieldClass)
3098+
}
3099+
}
3100+
3101+
type RemoteFieldRemoteFieldClassVisitor interface {
3102+
VisitString(string) error
3103+
VisitRemoteFieldClass(*RemoteFieldClass) error
3104+
}
3105+
3106+
func (r *RemoteFieldRemoteFieldClass) Accept(visitor RemoteFieldRemoteFieldClassVisitor) error {
3107+
switch r.typeName {
3108+
default:
3109+
return fmt.Errorf("invalid type %s in %T", r.typeName, r)
3110+
case "string":
3111+
return visitor.VisitString(r.String)
3112+
case "remoteFieldClass":
3113+
return visitor.VisitRemoteFieldClass(r.RemoteFieldClass)
3114+
}
3115+
}
3116+
30603117
type RemoteFieldRequest struct {
30613118
RemoteFieldClass *RemoteFieldRequestRemoteFieldClass `json:"remote_field_class,omitempty"`
30623119
Value map[string]any `json:"value,omitempty"`

0 commit comments

Comments
 (0)