pify/fulfillment
Fulfillments of an order: read the fulfillment orders and the fulfillments already made, create a fulfillment with its tracking, change the tracking of a fulfillment, cancel a fulfillment, and record an event of a fulfillment, such as its delivery. A fulfillment order can be released from its holds, reported in progress and marked open again.
Shopify splits an order into fulfillment orders, one per location that
ships it. A fulfillment takes units from the open fulfillment orders of
one location. fulfillmentCreate takes no idempotency key, so a caller
reads for_order before it creates, to find a fulfillment an earlier
call made.
Every call needs one of the write_*_fulfillment_orders scopes; a
merchant’s own locations need write_merchant_managed_fulfillment_orders.
create_event needs write_fulfillments as well. release_hold,
report_progress and open need only the first.
Types
pub type Fulfillment {
Fulfillment(
id: String,
status: FulfillmentStatus,
display_status: option.Option(FulfillmentDisplayStatus),
tracking_numbers: List(String),
line_items: List(FulfillmentLineItem),
)
}
Constructors
-
Fulfillment( id: String, status: FulfillmentStatus, display_status: option.Option(FulfillmentDisplayStatus), tracking_numbers: List(String), line_items: List(FulfillmentLineItem), )Arguments
- display_status
-
The state the admin shows, which the latest event sets.
Nonewhen Shopify sends none.
pub type FulfillmentDisplayStatus {
FulfillmentDisplayStatusAttemptedDelivery
FulfillmentDisplayStatusCanceled
FulfillmentDisplayStatusCarrierPickedUp
FulfillmentDisplayStatusConfirmed
FulfillmentDisplayStatusDelayed
FulfillmentDisplayStatusDelivered
FulfillmentDisplayStatusFailure
FulfillmentDisplayStatusFulfilled
FulfillmentDisplayStatusInTransit
FulfillmentDisplayStatusLabelPrinted
FulfillmentDisplayStatusLabelPurchased
FulfillmentDisplayStatusLabelVoided
FulfillmentDisplayStatusMarkedAsFulfilled
FulfillmentDisplayStatusNotDelivered
FulfillmentDisplayStatusOutForDelivery
FulfillmentDisplayStatusPickedUp
FulfillmentDisplayStatusReadyForPickup
FulfillmentDisplayStatusSubmitted
FulfillmentDisplayStatusOther(raw: String)
}
Constructors
-
FulfillmentDisplayStatusAttemptedDelivery -
FulfillmentDisplayStatusCanceled -
FulfillmentDisplayStatusCarrierPickedUp -
FulfillmentDisplayStatusConfirmed -
FulfillmentDisplayStatusDelayed -
FulfillmentDisplayStatusDelivered -
FulfillmentDisplayStatusFailure -
FulfillmentDisplayStatusFulfilled -
FulfillmentDisplayStatusInTransit -
FulfillmentDisplayStatusLabelPrinted -
FulfillmentDisplayStatusLabelPurchased -
FulfillmentDisplayStatusLabelVoided -
FulfillmentDisplayStatusMarkedAsFulfilled -
FulfillmentDisplayStatusNotDelivered -
FulfillmentDisplayStatusOutForDelivery -
FulfillmentDisplayStatusPickedUp -
FulfillmentDisplayStatusReadyForPickup -
FulfillmentDisplayStatusSubmitted -
FulfillmentDisplayStatusOther(raw: String)A value this library does not know.
What an event of a fulfillment records.
pub type FulfillmentEventStatus {
FulfillmentEventStatusAttemptedDelivery
FulfillmentEventStatusCarrierPickedUp
FulfillmentEventStatusConfirmed
FulfillmentEventStatusDelayed
FulfillmentEventStatusDelivered
FulfillmentEventStatusFailure
FulfillmentEventStatusInTransit
FulfillmentEventStatusLabelPrinted
FulfillmentEventStatusLabelPurchased
FulfillmentEventStatusOutForDelivery
FulfillmentEventStatusReadyForPickup
}
Constructors
-
FulfillmentEventStatusAttemptedDelivery -
FulfillmentEventStatusCarrierPickedUp -
FulfillmentEventStatusConfirmed -
FulfillmentEventStatusDelayed -
FulfillmentEventStatusDelivered -
FulfillmentEventStatusFailure -
FulfillmentEventStatusInTransit -
FulfillmentEventStatusLabelPrinted -
FulfillmentEventStatusLabelPurchased -
FulfillmentEventStatusOutForDelivery -
FulfillmentEventStatusReadyForPickup
pub type FulfillmentHold {
FulfillmentHold(id: String, reason: FulfillmentHoldReason)
}
Constructors
-
FulfillmentHold(id: String, reason: FulfillmentHoldReason)
Why a fulfillment order is on hold.
pub type FulfillmentHoldReason {
FulfillmentHoldReasonAwaitingPayment
FulfillmentHoldReasonAwaitingReturnItems
FulfillmentHoldReasonHighRiskOfFraud
FulfillmentHoldReasonIncorrectAddress
FulfillmentHoldReasonInventoryOutOfStock
FulfillmentHoldReasonOnlineStorePostPurchaseCrossSell
FulfillmentHoldReasonOther
FulfillmentHoldReasonUnknownDeliveryDate
FulfillmentHoldReasonUnknown(raw: String)
}
Constructors
-
FulfillmentHoldReasonAwaitingPayment -
FulfillmentHoldReasonAwaitingReturnItems -
FulfillmentHoldReasonHighRiskOfFraud -
FulfillmentHoldReasonIncorrectAddress -
FulfillmentHoldReasonInventoryOutOfStock -
FulfillmentHoldReasonOnlineStorePostPurchaseCrossSell -
FulfillmentHoldReasonOtherShopify’s
OTHER, such as a hold the merchant placed by hand. -
FulfillmentHoldReasonUnknownDeliveryDate -
FulfillmentHoldReasonUnknown(raw: String)A value this library does not know.
pub type FulfillmentLineItem {
FulfillmentLineItem(
line_item_id: String,
sku: option.Option(String),
quantity: Int,
)
}
Constructors
-
FulfillmentLineItem( line_item_id: String, sku: option.Option(String), quantity: Int, )
pub type FulfillmentOrder {
FulfillmentOrder(
id: String,
status: FulfillmentOrderStatus,
location_id: option.Option(String),
holds: List(FulfillmentHold),
supported_actions: List(FulfillmentOrderAction),
line_items: List(FulfillmentOrderLineItem),
)
}
Constructors
-
FulfillmentOrder( id: String, status: FulfillmentOrderStatus, location_id: option.Option(String), holds: List(FulfillmentHold), supported_actions: List(FulfillmentOrderAction), line_items: List(FulfillmentOrderLineItem), )Arguments
- location_id
-
The location that ships it.
Nonewhen the location is gone. - holds
-
The holds on it (
fulfillmentHolds). - supported_actions
-
What Shopify lets the app do with it now (
supportedActions).
An action Shopify supports on a fulfillment order.
pub type FulfillmentOrderAction {
FulfillmentOrderActionCancelFulfillmentOrder
FulfillmentOrderActionCreateFulfillment
FulfillmentOrderActionExternal
FulfillmentOrderActionHold
FulfillmentOrderActionMarkAsOpen
FulfillmentOrderActionMerge
FulfillmentOrderActionMove
FulfillmentOrderActionReleaseHold
FulfillmentOrderActionReportProgress
FulfillmentOrderActionRequestCancellation
FulfillmentOrderActionRequestFulfillment
FulfillmentOrderActionSplit
FulfillmentOrderActionOther(raw: String)
}
Constructors
-
FulfillmentOrderActionCancelFulfillmentOrder -
FulfillmentOrderActionCreateFulfillment -
FulfillmentOrderActionExternal -
FulfillmentOrderActionHold -
FulfillmentOrderActionMarkAsOpen -
FulfillmentOrderActionMerge -
FulfillmentOrderActionMove -
FulfillmentOrderActionReleaseHold -
FulfillmentOrderActionReportProgress -
FulfillmentOrderActionRequestCancellation -
FulfillmentOrderActionRequestFulfillment -
FulfillmentOrderActionSplit -
FulfillmentOrderActionOther(raw: String)A value this library does not know.
pub type FulfillmentOrderLineItem {
FulfillmentOrderLineItem(
id: String,
line_item_id: String,
sku: option.Option(String),
remaining_quantity: Int,
)
}
Constructors
-
FulfillmentOrderLineItem( id: String, line_item_id: String, sku: option.Option(String), remaining_quantity: Int, )Arguments
- line_item_id
-
The order line item it fulfils.
- remaining_quantity
-
The units still to fulfil.
The units of one fulfillment order a fulfillment takes.
pub type FulfillmentOrderLines {
FulfillmentOrderLines(
fulfillment_order_id: String,
line_items: List(LineQuantity),
)
}
Constructors
-
FulfillmentOrderLines( fulfillment_order_id: String, line_items: List(LineQuantity), )
pub type FulfillmentOrderStatus {
FulfillmentOrderStatusOpen
FulfillmentOrderStatusInProgress
FulfillmentOrderStatusScheduled
FulfillmentOrderStatusOnHold
FulfillmentOrderStatusClosed
FulfillmentOrderStatusCancelled
FulfillmentOrderStatusIncomplete
FulfillmentOrderStatusOther(raw: String)
}
Constructors
-
FulfillmentOrderStatusOpen -
FulfillmentOrderStatusInProgress -
FulfillmentOrderStatusScheduled -
FulfillmentOrderStatusOnHold -
FulfillmentOrderStatusClosed -
FulfillmentOrderStatusCancelled -
FulfillmentOrderStatusIncomplete -
FulfillmentOrderStatusOther(raw: String)A value this library does not know.
A fulfillment order as Shopify stored it after a write.
pub type FulfillmentOrderWritten {
FulfillmentOrderWritten(
id: String,
status: FulfillmentOrderStatus,
supported_actions: List(FulfillmentOrderAction),
)
}
Constructors
-
FulfillmentOrderWritten( id: String, status: FulfillmentOrderStatus, supported_actions: List(FulfillmentOrderAction), )
pub type FulfillmentStatus {
FulfillmentStatusSuccess
FulfillmentStatusCancelled
FulfillmentStatusFailure
FulfillmentStatusPending
FulfillmentStatusOpen
FulfillmentStatusError
FulfillmentStatusOther(raw: String)
}
Constructors
-
FulfillmentStatusSuccess -
FulfillmentStatusCancelled -
FulfillmentStatusFailure -
FulfillmentStatusPending -
FulfillmentStatusOpen -
FulfillmentStatusError -
FulfillmentStatusOther(raw: String)A value this library does not know.
Units of one fulfillment order line item.
pub type LineQuantity {
LineQuantity(
fulfillment_order_line_item_id: String,
quantity: Int,
)
}
Constructors
-
LineQuantity( fulfillment_order_line_item_id: String, quantity: Int, )
Whether Shopify e-mails the buyer about the fulfillment.
pub type Notice {
NoticeNotifyCustomer
NoticeSilent
}
Constructors
-
NoticeNotifyCustomer -
NoticeSilent
What an order holds to fulfil and what it already shipped.
pub type OrderFulfillments {
OrderFulfillments(
fulfillment_orders: List(FulfillmentOrder),
fulfillments: List(Fulfillment),
read: Read,
)
}
Constructors
-
OrderFulfillments( fulfillment_orders: List(FulfillmentOrder), fulfillments: List(Fulfillment), read: Read, )Arguments
- read
-
Whether the read holds every fulfillment order, line and fulfillment.
pub type Read {
ReadComplete
ReadTruncated
}
Constructors
-
ReadComplete -
ReadTruncatedThe order has more fulfillment orders, lines or fulfillments than one read returns.
pub type Tracking {
Tracking(
number: String,
company: option.Option(String),
url: option.Option(String),
)
}
Constructors
-
Tracking( number: String, company: option.Option(String), url: option.Option(String), )
A fulfillment as Shopify stored it after a write.
pub type Written {
Written(id: String, status: FulfillmentStatus)
}
Constructors
-
Written(id: String, status: FulfillmentStatus)
Values
pub fn accepts_fulfillment(
status: FulfillmentOrderStatus,
) -> Bool
Only an open or started fulfillment order takes a new fulfillment.
pub fn cancel(
client: pify.Client,
fulfillment_id: String,
) -> effect.Effect(Result(Written, error.ShopifyError), key)
Cancel a fulfillment. Shopify gives its units back to fulfillment orders, so they can be fulfilled again.
pub const cancel_mutation: String
pub fn cancel_variables(fulfillment_id: String) -> json.Json
pub fn create(
client: pify.Client,
lines: List(FulfillmentOrderLines),
tracking: option.Option(Tracking),
notice: Notice,
) -> effect.Effect(Result(Written, error.ShopifyError), key)
Create one fulfillment over fulfillment orders of one location.
pub fn create_event(
client: pify.Client,
fulfillment_id: String,
status: FulfillmentEventStatus,
happened_at: option.Option(String),
) -> effect.Effect(Result(String, error.ShopifyError), key)
Record an event of a fulfillment. happened_at is an ISO 8601 date and
time; without it Shopify takes the time of the call. Answers the event id.
pub const create_event_mutation: String
pub fn create_event_variables(
fulfillment_id: String,
status: FulfillmentEventStatus,
happened_at: option.Option(String),
) -> json.Json
pub const create_mutation: String
pub fn create_variables(
lines: List(FulfillmentOrderLines),
tracking: option.Option(Tracking),
notice: Notice,
) -> json.Json
pub fn event_status_to_string(
status: FulfillmentEventStatus,
) -> String
pub const events_scope: String
The scope that lets an app record the events of a fulfillment.
pub fn for_order(
client: pify.Client,
order_id: String,
) -> effect.Effect(
Result(option.Option(OrderFulfillments), error.ShopifyError),
key,
)
The order’s fulfillment orders of any status and its fulfillments, in
one read under the 1000-point cap. Ok(None) when no order has the id.
pub fn for_order_decoder() -> decode.Decoder(
option.Option(OrderFulfillments),
)
pub fn for_order_query() -> String
pub fn for_order_variables(order_id: String) -> json.Json
pub fn fulfillment_order_variables(
fulfillment_order_id: String,
) -> json.Json
pub const fulfillment_orders_per_read: Int
Fulfillment orders per read. Each costs its line items.
pub const fulfillments_per_read: Int
Fulfillments per read. Order.fulfillments is a list, not a connection:
a full list may hold more.
pub const line_items_per_fulfillment: Int
Lines per fulfillment read.
pub const line_items_per_fulfillment_order: Int
Line items per fulfillment order read.
pub const merchant_managed_scope: String
The scope that lets an app fulfil the orders of the merchant’s own locations. It grants the read scope too.
pub fn open(
client: pify.Client,
fulfillment_order_id: String,
) -> effect.Effect(
Result(FulfillmentOrderWritten, error.ShopifyError),
key,
)
Mark a fulfillment order open: a scheduled one, or one of the merchant’s own locations that had progress reported.
pub const open_mutation: String
pub fn parse_fulfillment_display_status(
raw: String,
) -> FulfillmentDisplayStatus
pub fn parse_fulfillment_hold_reason(
raw: String,
) -> FulfillmentHoldReason
pub fn parse_fulfillment_order_action(
raw: String,
) -> FulfillmentOrderAction
pub fn parse_fulfillment_order_status(
raw: String,
) -> FulfillmentOrderStatus
pub fn parse_fulfillment_status(raw: String) -> FulfillmentStatus
pub fn release_hold(
client: pify.Client,
fulfillment_order_id: String,
hold_ids: List(String),
) -> effect.Effect(
Result(FulfillmentOrderWritten, error.ShopifyError),
key,
)
Release holds of a fulfillment order. Shopify releases every hold when
hold_ids is empty, so a caller names the holds it read.
pub const release_hold_mutation: String
pub fn release_hold_variables(
fulfillment_order_id: String,
hold_ids: List(String),
) -> json.Json
pub fn report_progress(
client: pify.Client,
fulfillment_order_id: String,
) -> effect.Effect(
Result(FulfillmentOrderWritten, error.ShopifyError),
key,
)
Report that the merchant started on an open or in-progress fulfillment
order. An open one moves to IN_PROGRESS.
pub const report_progress_mutation: String
pub fn ships_goods(status: FulfillmentStatus) -> Bool
A cancelled, failed or refused fulfillment ships nothing.
pub fn supports(
actions: List(FulfillmentOrderAction),
action: FulfillmentOrderAction,
) -> Bool
Whether Shopify listed action among the fulfillment order’s supported
actions when it was read.
pub fn update_tracking(
client: pify.Client,
fulfillment_id: String,
tracking: Tracking,
notice: Notice,
) -> effect.Effect(Result(Written, error.ShopifyError), key)
Replace the tracking of a fulfillment.
pub const update_tracking_mutation: String