pify
Types
pub opaque type AccessToken
pub type AdminApiClientConfig {
AdminApiClientConfig(
store_domain: String,
api_version: String,
access_token: String,
headers: #(String, List(#(String, String))),
api_url: String,
retries: option.Option(Int),
)
}
Constructors
-
AdminApiClientConfig( store_domain: String, api_version: String, access_token: String, headers: #(String, List(#(String, String))), api_url: String, retries: option.Option(Int), )
pub type AdminClientResponse(msg) {
AdminClientResponse(data: option.Option(msg))
}
Constructors
-
AdminClientResponse(data: option.Option(msg))
pub type AdminHandler(msg) {
AdminHandler(
config: AdminApiClientConfig,
fetch: fn(
String,
option.Option(json.Json),
decode.Decoder(AdminClientResponse(msg)),
) -> task.Effect(
AdminClientResponse(msg),
AdminResponseErrors,
),
)
}
Constructors
-
AdminHandler( config: AdminApiClientConfig, fetch: fn( String, option.Option(json.Json), decode.Decoder(AdminClientResponse(msg)), ) -> task.Effect(AdminClientResponse(msg), AdminResponseErrors), )
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 AdminResponseErrors {
AdminResponseErrors(
network_status_code: option.Option(Int),
message: option.Option(String),
graphql_errors: option.Option(List(String)),
response: option.Option(response.Response(String)),
)
}
Constructors
-
AdminResponseErrors( network_status_code: option.Option(Int), message: option.Option(String), graphql_errors: option.Option(List(String)), response: option.Option(response.Response(String)), )
pub type CreateAdminApiClient {
CreateAdminApiClient(
store_domain: String,
api_version: String,
access_token: String,
retries: option.Option(Int),
)
}
Constructors
-
CreateAdminApiClient( store_domain: String, api_version: String, access_token: String, retries: option.Option(Int), )
Arguments
- store_domain
-
The domain of the store.
- api_version
-
The requested Admin API version.
- access_token
-
Admin API private access token.
- 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 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 ErrorReason {
ErrorReason(error: String, message: String)
}
Constructors
-
ErrorReason(error: String, message: String)
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),
) -> task.Effect(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)) -> task.Effect( 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 admin_handler(
config: AdminApiClientConfig,
) -> AdminHandler(msg)
pub fn admin_response_errors_decoder() -> decode.Decoder(
AdminResponseErrors,
)
pub fn create_admin_api_client(
config: CreateAdminApiClient,
) -> Result(AdminApiClientConfig, ShopifyError)
pub fn create_store_front_api_client(
config: CreateStorefrontApiClient,
) -> Result(StorefrontApiClientConfig, ShopifyError)
pub fn handler(
config: StorefrontApiClientConfig,
) -> ShopifyHandler(msg)