Skip to content

Commit 6594dc7

Browse files
committed
#patch: break wait loop instead of returning order read
1 parent 8f08a36 commit 6594dc7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

docs/resources/order.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Mailform order
2323
- `from_name` (String) The name of the sender of this envelope or postcard.
2424
- `from_postcode` (String) The address postcode or zip code of the sender of this envelope or postcard. Example "00000"
2525
- `from_state` (String) The address state of the sender of this envelope or postcard. Example "WA"
26-
- `service` (String) What shipping service/speed to use.
26+
- `service` (String) What shipping service/speed to use. Must be one of: `FEDEX_OVERNIGHT`, `USPS_PRIORITY_EXPRESS`, `USPS_PRIORITY`, `USPS_CERTIFIED_PHYSICAL_RECEIPT`, `USPS_CERTIFIED_RECEIPT`, `USPS_CERTIFIED`, `USPS_FIRST_CLASS`, `USPS_STANDARD`, `USPS_POSTCARD`
2727
- `to_address_1` (String) The street number and name of the recipient of this envelope or postcard.
2828
- `to_city` (String) The address state of the recipient of this envelope or postcard.
2929
- `to_country` (String) The address country of the recipient of this envelope or postcard. Example "US"

internal/provider/resource_mailform_order.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"strings"
78
"time"
89

910
"github.com/circa10a/go-mailform"
@@ -45,7 +46,7 @@ var orderInputSchema = map[string]*schema.Schema{
4546
ForceNew: true,
4647
},
4748
"service": {
48-
Description: "What shipping service/speed to use.",
49+
Description: fmt.Sprintf("What shipping service/speed to use. Must be one of: `%s`", strings.Join(mailform.ServiceCodes, "`, `")),
4950
Type: schema.TypeString,
5051
Required: true,
5152
ValidateFunc: validation.StringInSlice(mailform.ServiceCodes, false),
@@ -325,14 +326,16 @@ func resourceMailformOrderCreate(ctx context.Context, d *schema.ResourceData, m
325326
}
326327
orderStatus := order.Data.State
327328
tflog.Debug(ctx, fmt.Sprintf("order state: %s", orderStatus))
328-
// If order has been mailed
329-
if orderStatus == mailform.StatusFulfilled {
330-
return orderRead(ctx, d, m)
331-
}
329+
332330
// If order was cancelled, break
333331
if orderStatus == mailform.StatusCancelled {
334332
return diag.FromErr(errOrderCancelled)
335333
}
334+
335+
// If order has been mailed
336+
if orderStatus == mailform.StatusFulfilled {
337+
break
338+
}
336339
select {
337340
case <-timer.C:
338341
return diag.FromErr(errors.New("waiting for order to be fulfilled timed out"))

0 commit comments

Comments
 (0)