Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -3109,7 +3109,7 @@ type MembersUpdateParamsUser struct {
```

<a name="Membership"></a>
## type [Membership](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L20-L52>)
## type [Membership](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L19-L51>)

A membership associates a user with a resource, memberships is defined by user, resource, resource type, and associated roles.

Expand Down Expand Up @@ -3150,7 +3150,7 @@ type Membership struct {
```

<a name="MembershipResource"></a>
## type [MembershipResource](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L55-L75>)
## type [MembershipResource](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L54-L74>)

Information about the resource the membership is in.

Expand Down Expand Up @@ -3249,7 +3249,7 @@ type MembershipUserClassic struct {
```

<a name="MembershipsClient"></a>
## type [MembershipsClient](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L182-L184>)
## type [MembershipsClient](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L175-L177>)

MembershipsClient provides access to the Memberships API.

Expand All @@ -3262,7 +3262,7 @@ type MembershipsClient struct {
```

<a name="NewMembershipsClient"></a>
### func [NewMembershipsClient](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L186>)
### func [NewMembershipsClient](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L179>)

```go
func NewMembershipsClient(c *client.Client) *MembershipsClient
Expand All @@ -3271,7 +3271,7 @@ func NewMembershipsClient(c *client.Client) *MembershipsClient


<a name="MembershipsClient.List"></a>
### func \(\*MembershipsClient\) [List](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L191>)
### func \(\*MembershipsClient\) [List](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L184>)

```go
func (c *MembershipsClient) List(ctx context.Context, params MembershipsListParams) (*MembershipsListResponse, error)
Expand All @@ -3280,7 +3280,7 @@ func (c *MembershipsClient) List(ctx context.Context, params MembershipsListPara
List memberships of the current user.

<a name="MembershipsListParams"></a>
## type [MembershipsListParams](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L84-L111>)
## type [MembershipsListParams](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L83-L112>)

MembershipsListParams are query parameters for ListMemberships.

Expand All @@ -3299,13 +3299,15 @@ type MembershipsListParams struct {
// Filter memberships by the name of the resource the membership is in.
ResourceName *string
// Filter memberships by the parent of the resource the membership is in.
// When filtering by parent both `resource.parent.id` and `resource.parent.type` must be present. Pass explicit null
// to filter for resources without a parent.
ResourceParentID *nullable.Field[string]
// Omit both `resource.parent.id` and `resource.parent.type` to skip parent filtering. When filtering by parent,
// both parameters must be present. To select resources without a parent, set each parameter to an empty value.
// Otherwise, both parameters must identify a parent.
ResourceParentID *string
// Filter memberships by the parent of the resource the membership is in.
// When filtering by parent both `resource.parent.id` and `resource.parent.type` must be present. Pass explicit null
// to filter for resources without a parent.
ResourceParentType *nullable.Field[ResourceType]
// Omit both `resource.parent.id` and `resource.parent.type` to skip parent filtering. When filtering by parent,
// both parameters must be present. To select resources without a parent, set each parameter to an empty value.
// Otherwise, both parameters must identify a parent.
ResourceParentType *ResourceType
// Filter memberships by resource kind.
ResourceType *ResourceType
// Filter the returned memberships by role.
Expand All @@ -3316,7 +3318,7 @@ type MembershipsListParams struct {
```

<a name="MembershipsListParams.QueryValues"></a>
### func \(\*MembershipsListParams\) [QueryValues](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L114>)
### func \(\*MembershipsListParams\) [QueryValues](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L115>)

```go
func (p *MembershipsListParams) QueryValues() url.Values
Expand All @@ -3325,7 +3327,7 @@ func (p *MembershipsListParams) QueryValues() url.Values
QueryValues converts [MembershipsListParams](<#MembershipsListParams>) into \[url.Values\].

<a name="MembershipsListResponse"></a>
## type [MembershipsListResponse](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L173-L176>)
## type [MembershipsListResponse](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L166-L169>)

MembershipsListResponse is a schema definition.

Expand Down Expand Up @@ -4816,7 +4818,7 @@ func (p *ReceiptsGetParams) QueryValues() url.Values
QueryValues converts [ReceiptsGetParams](<#ReceiptsGetParams>) into \[url.Values\].

<a name="ResourceType"></a>
## type [ResourceType](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L81>)
## type [ResourceType](<https://github.com/sumup/sumup-go/blob/main/memberships.go#L80>)

The type of the membership resource. Possible values are: \* \`merchant\` \- merchant account\(s\) \* \`organization\` \- organization\(s\)

Expand Down
4 changes: 0 additions & 4 deletions internal/cmd/codegen/pkg/builder/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ func (b *Builder) pathsToParamTypes(tagName string, paths *v3.Paths) []Writable

optional := param.Required == nil || !*param.Required
pointer := shouldUsePointer(optional, param.Schema, typ)
if isNullableSchema(param.Schema) {
typ = "nullable.Field[" + typ + "]"
pointer = optional
}
fields = append(fields, StructField{
Name: name,
Type: typ,
Expand Down
22 changes: 1 addition & 21 deletions internal/cmd/codegen/pkg/builder/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,27 +276,7 @@ func (e toQueryValues) String() string {
fmt.Fprintf(buf, "\tq := make(url.Values)\n\n")
for _, f := range e.Typ.Fields {
name := strcase.ToCamel(f.Name)
if isNullableSchema(f.Parameter.Schema) {
field := fmt.Sprintf("p.%s", name)
if f.Pointer {
fmt.Fprintf(buf, "\tif %s != nil {\n", field)
}
fmt.Fprintf(buf, "\tif %s.Null() {\n", field)
fmt.Fprintf(buf, "\t\tq.Set(%q, %q)\n", f.Name, "null")
fmt.Fprint(buf, "\t} else {\n")
schema := dereferenceSchema(f.Parameter.Schema)
if schema != nil && schema.Schema() != nil && isArraySchema(schema.Schema()) {
fmt.Fprintf(buf, "\t\tfor _, v := range *%s.Value() {\n", field)
fmt.Fprintf(buf, "\t\t\tq.Add(%q, %s)\n", f.Name, schemaToString("v", schema.Schema().Items.A))
fmt.Fprint(buf, "\t\t}\n")
} else {
fmt.Fprintf(buf, "\t\tq.Set(%q, %s)\n", f.Name, paramToString("*"+field+".Value()", f.Parameter))
}
fmt.Fprint(buf, "\t}\n")
if f.Pointer {
fmt.Fprint(buf, "\t}\n")
}
} else if f.Parameter.Schema != nil && f.Parameter.Schema.Schema() != nil && slices.Contains(f.Parameter.Schema.Schema().Type, "array") {
if f.Parameter.Schema != nil && f.Parameter.Schema.Schema() != nil && slices.Contains(f.Parameter.Schema.Schema().Type, "array") {
field := fmt.Sprintf("p.%s", name)
fmt.Fprintf(buf, "\tfor _, v := range %s {\n", field)
fmt.Fprintf(buf, "\t\tq.Add(%q, %s)\n", f.Name, paramToString("v", f.Parameter))
Expand Down
27 changes: 10 additions & 17 deletions memberships.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 6 additions & 14 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3454,27 +3454,19 @@
{
"name": "resource.parent.id",
"in": "query",
"description": "Filter memberships by the parent of the resource the membership is in.\nWhen filtering by parent both `resource.parent.id` and `resource.parent.type` must be present. Pass explicit null to filter for resources without a parent.",
"allowEmptyValue": true,
"description": "Filter memberships by the parent of the resource the membership is in.\nOmit both `resource.parent.id` and `resource.parent.type` to skip parent filtering. When filtering by parent, both parameters must be present. To select resources without a parent, set each parameter to an empty value. Otherwise, both parameters must identify a parent.",
"schema": {
"type": [
"string",
"null"
]
"type": "string"
}
},
{
"name": "resource.parent.type",
"in": "query",
"description": "Filter memberships by the parent of the resource the membership is in.\nWhen filtering by parent both `resource.parent.id` and `resource.parent.type` must be present. Pass explicit null to filter for resources without a parent.",
"allowEmptyValue": true,
"description": "Filter memberships by the parent of the resource the membership is in.\nOmit both `resource.parent.id` and `resource.parent.type` to skip parent filtering. When filtering by parent, both parameters must be present. To select resources without a parent, set each parameter to an empty value. Otherwise, both parameters must identify a parent.",
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/ResourceType"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/ResourceType"
}
},
{
Expand Down
Loading