storefront
Types
pub opaque type AccessToken
pub type CreateStorefrontApiClient {
CreateStorefrontApiClient(
store_domain: String,
api_version: option.Option(String),
public_access_token: option.Option(String),
private_access_token: option.Option(String),
client_name: option.Option(String),
retries: option.Option(Int),
)
}
Constructors
-
CreateStorefrontApiClient( store_domain: String, api_version: option.Option(String), public_access_token: option.Option(String), private_access_token: option.Option(String), client_name: option.Option(String), retries: option.Option(Int), )
Arguments
- store_domain
-
The domain of the store. It can be the Shopify myshopify.com domain or a custom store domain.
- api_version
-
The requested Storefront API version.
- public_access_token
-
Storefront API public access token. Either publicAccessToken or privateAccessToken must be provided at initialization.
- private_access_token
-
Storefront API private access token. Either publicAccessToken or privateAccessToken must be provided at initialization. Important: Storefront API private delegate access tokens should only be used in a server-to-server implementation.
- client_name
-
Name of the client
- retries
-
The number of HTTP request retries if the request was abandoned or the server responded with a Too Many Requests (429) or Service Unavailable (503) response. Default value is 0. Maximum value is 3.
pub type ShopifyError {
BadUrl(String)
HttpError(response.Response(String))
JsonError(json.DecodeError)
NetworkError
UnhandledResponse(response.Response(String))
RateLimitError
ClientError(String)
}
Constructors
-
BadUrl(String)
-
HttpError(response.Response(String))
-
JsonError(json.DecodeError)
-
NetworkError
-
UnhandledResponse(response.Response(String))
-
RateLimitError
-
ClientError(String)
pub type ShopifyHandler(msg) {
ShopifyHandler(
config: StorefrontApiClientConfig,
get_headers: fn(
option.Option(#(String, List(#(String, String)))),
) -> #(String, List(#(String, String))),
fetch: fn(
String,
option.Option(json.Json),
decode.Decoder(msg),
) -> promise.Promise(Result(msg, ShopifyError)),
)
}
Constructors
-
ShopifyHandler( config: StorefrontApiClientConfig, get_headers: fn( option.Option(#(String, List(#(String, String)))), ) -> #(String, List(#(String, String))), fetch: fn(String, option.Option(json.Json), decode.Decoder(msg)) -> promise.Promise( Result(msg, ShopifyError), ), )
Arguments
- config
-
Configuration for the client
- fetch
-
Returns Storefront API specific headers needed to interact with the API. If additional headers are provided, the custom headers will be included in the returned headers object. Fetches data from Storefront API using the provided GQL operation string and ApiClientRequestOptions object and returns the network response.
pub type StorefrontApiClientConfig {
StorefrontApiClientConfig(
store_domain: String,
api_version: option.Option(String),
access_token: AccessToken,
headers: #(String, List(#(String, String))),
api_url: String,
client_name: option.Option(String),
retries: option.Option(Int),
)
}
Constructors
-
StorefrontApiClientConfig( store_domain: String, api_version: option.Option(String), access_token: AccessToken, headers: #(String, List(#(String, String))), api_url: String, client_name: option.Option(String), retries: option.Option(Int), )
Values
pub fn create_store_front_api_client(
config: CreateStorefrontApiClient,
) -> Result(StorefrontApiClientConfig, ShopifyError)
pub fn handler(
config: StorefrontApiClientConfig,
) -> ShopifyHandler(msg)