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
89 changes: 89 additions & 0 deletions fixed_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,95 @@ func TestFixedSubscription_Create(t *testing.T) {
assert.Equal(t, 111614, actual)
}

func TestFixedSubscription_Create_Marketplace(t *testing.T) {
server := httptest.NewServer(
testServer(
"apiKey", "secret",
postRequest(
t,
"/fixed/subscriptions",
`{
"name": "My test fixed subscription with marketplace payments",
"planId": 34811,
"paymentMethod": "marketplace"
}`,
`{
"taskId": "2a6c6c5b-a16a-4f19-a803-17c1013a5888",
"commandType": "fixedSubscriptionCreateRequest",
"status": "received",
"description": "Task request received and is being queued for processing.",
"timestamp": "2024-05-09T09:36:16.122289471Z",
"links": [
{
"rel": "task",
"type": "GET",
"href": "https://api-staging.qa.redislabs.com/v1/tasks/2a6c6c5b-a16a-4f19-a803-17c1013a5888"
}
]
}`,
),
getRequest(
t,
"/tasks/2a6c6c5b-a16a-4f19-a803-17c1013a5888",
`{
"taskId": "2a6c6c5b-a16a-4f19-a803-17c1013a5888",
"commandType": "fixedSubscriptionCreateRequest",
"status": "initialized",
"timestamp": "2020-10-28T09:58:16.798Z",
"response": {},
"_links": {
"self": {
"href": "https://example.com",
"type": "GET"
}
}
}`,
),
getRequest(
t,
"/tasks/2a6c6c5b-a16a-4f19-a803-17c1013a5888",
`{
"taskId": "2a6c6c5b-a16a-4f19-a803-17c1013a5888",
"commandType": "fixedSubscriptionCreateRequest",
"status": "processing-completed",
"description": "Request processing completed successfully and its resources are now being provisioned / de-provisioned.",
"timestamp": "2024-05-09T09:36:35.177603409Z",
"response": {
"resourceId": 111191
},
"links": [
{
"rel": "resource",
"type": "GET",
"href": "https://api-staging.qa.redislabs.com/v1/fixed/subscriptions/111191"
},
{
"rel": "self",
"type": "GET",
"href": "https://api-staging.qa.redislabs.com/v1/tasks/2a6c6c5b-a16a-4f19-a803-17c1013a5888"
}
]
}`,
),
),
)

subject, err := clientFromTestServer(server, "apiKey", "secret")
require.NoError(t, err)

actual, err := subject.FixedSubscriptions.Create(
context.TODO(),
fixedSubscriptions.FixedSubscription{
Name: redis.String("My test fixed subscription with marketplace payments"),
PlanId: redis.Int(34811),
PaymentMethod: redis.String("marketplace"),
},
)

require.NoError(t, err)
assert.Equal(t, 111191, actual)
}

func TestFixedSubscription_List(t *testing.T) {
server := httptest.NewServer(
testServer(
Expand Down
1 change: 1 addition & 0 deletions service/fixed/subscriptions/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type FixedSubscription struct {
Name *string `json:"name,omitempty"`
Status *string `json:"status,omitempty"` // Omit for Create and Update
PlanId *int `json:"planId,omitempty"`
PaymentMethod *string `json:"paymentMethod,omitempty"`
PaymentMethodID *int `json:"paymentMethodId,omitempty"`
CreationDate *time.Time `json:"creationDate,omitempty"` // Omit for Create and Update
}
Expand Down
Loading