shopbuilder_api v0.1.27 ExSbapi View Source

Elixir Wrapper Around Shopbuilder API

Link to this section Summary

Functions

Creates a product collection to the given website_url using the provided arguments

Creates a product to the given website_url with a provided product_object

Returns {:ok,_ } or {:error, %{reason: "unauthorized"}}

Builds a new ExSbapi.Collection struct using the provided arguments

Deletes the option with the given option_id from the given website_url

Fetchs all product collections from the given website_url

Gets the option with the given option_id from the given website_url

Gets the sublevel menu link with the given menu_id from the given website_url

This function is expecting list_of_uuid,date, access_token and client

Initiates a product bulk operation that can create, update or delete a set of products (up to 20 products) in a single request to the given website_url

Initiates a sublevel menu link bulk operation that can update a set of sublevel menu links in a single request to the given website_url

Updates a sublevel menu link with the given menu_id to the given website_url

Link to this section Functions

Link to this function add_collection(website_url, access_token, title, description \\ "", image \\ nil, ref \\ "", format \\ "json") View Source
add_collection(binary(), binary(), any(), binary(), any(), map(), binary()) ::
  {:ok, Response.t()} | {:error, Response.t()} | {:error, Error.t()}

Creates a product collection to the given website_url using the provided arguments.

Arguments

  • title - a unique string for the product variation.
  • description - description for the variarion
  • image - an Image struct
  • ref - a reference string

Makes a POST request to the given website_url using the OAuth2.AccessToken.

Link to this function add_coupon(code_value, order_id, website_url, access_token, format \\ "json") View Source
Link to this function add_custom_shipping(website_url, access_token, body) View Source
Link to this function add_customer_profile(params) View Source
Link to this function add_customer_profile_to_order(params) View Source
Link to this function add_email(value, order_id, website_url, access_token, format \\ "json") View Source
Link to this function add_option(website_url, access_token, name, is_attribute \\ false, is_searchable \\ false, is_default_visible \\ false, show_as_button \\ false, facet_widget_type \\ "facetapi_checkbox_links", bundle_type \\ "shop_builder", format \\ "json") View Source

Creates a product option to the given website_url with the provided arguments.

Arguments

  • name - name of the option.
  • bundle_type - “shop_builder” or “digital_goods”, bundle type to which this option is available.
  • is_attribute - boolean, to indicate if this option is an attribute.
  • is_searchable - boolean, to indicate if this option should be added as a filter in the shop page.
  • is_default_visible - boolean, to indicate if this option should show when adding products.
  • show_as_button - boolean, to indicate if this option should show as a button in the product page.
  • facet_widget_type - string, provide the facet filter widget type.

Makes a POST request to the given website_url using the OAuth2.AccessToken.

Link to this function add_payment(value, order_id, website_url, access_token, format \\ "json") View Source
Link to this function add_product(website_url, access_token, title, variations, collections, description \\ "", status \\ "1", images \\ [], ref \\ "", language \\ "en", new \\ true, on_sale \\ false, same_price \\ false, price \\ nil, same_weight_dimensions \\ false, weight \\ nil, dimensions \\ nil, suggested_products \\ nil, seo \\ nil, type \\ "shop_builder_display", format \\ "json") View Source

Creates a product to the given website_url with the provided arguments.

Arguments

  • title - title of the product.
  • variations - a list of ExSbapi.ProductVariation structs
  • collections - a list of ExSbapi.ProductType structs
  • description - description of the product.
  • status - “0” or “1”
  • images - a list of images
  • ref - a reference string
  • language - language code ex. “en”
  • new - boolean, to indicate if product is new
  • on_sale - boolean, to indicate if product is on sale
  • same_price - boolean, to indicate if all product variations has the same price
  • price - a ExSbapi.Price struct (will apply to all variations)
  • same_weight_dimensions - boolean, to indicate if all product variations has the same dimensions and weight
  • weight - a ExSbapi.ProductWeight struct (will apply to all variations)
  • dimensions - a ExSbapi.ProductDimensions struct (will apply to all variations)
  • suggested_products - a list of suggested products
  • seo - a tupple containing seo fields
  • type - ex. “shop_builder_display”

Makes a POST request to the given website_url using the OAuth2.AccessToken.

Link to this function add_product(website_url, access_token, product_object, format \\ "json") View Source
add_product(binary(), binary(), ExSbapi.Product.t(), binary()) ::
  {:ok, Response.t()} | {:error, Response.t()} | {:error, Error.t()}
add_product(binary(), binary(), any(), binary()) ::
  {:ok, Response.t()} | {:error, Response.t()} | {:error, Error.t()}

Creates a product to the given website_url with a provided product_object.

Makes a POST request to the given website_url using the OAuth2.AccessToken.

Link to this function add_shipping(value, order_id, website_url, access_token, format \\ "json") View Source
Link to this function authorize_url!(provider, scope, client) View Source

Returns {:ok,_ } or {:error, %{reason: "unauthorized"}}

Endpoint:

This function is being called from /lib/RtCheckoutWeb/templates/install/channel.js.eex by this.channel.join()

Params:

checkout:checkout_id , message, socket

Functionality:

It checks website_id and order_od that has been sent from client side with website_id and order_id that has been verified in user_socket.

Link to this function build_collection(title, description \\ "", image \\ nil, ref \\ "") View Source
build_collection(binary(), any(), map(), binary()) :: ExSbapi.Collection.t()

Builds a new ExSbapi.Collection struct using the provided arguments.

Arguments

  • title - a unique string for the product variation.
  • description - description for the variarion
  • image - an Image struct
  • ref - a reference string
Link to this function build_product(title, variations, collections, description \\ "", status \\ "1", images \\ [], ref \\ "", language \\ "en", new \\ true, on_sale \\ false, same_price \\ false, price \\ nil, same_weight_dimensions \\ false, weight \\ nil, dimensions \\ nil, suggested_products \\ nil, seo \\ nil, type \\ "shop_builder_display") View Source
build_product(
  binary(),
  list(),
  list(),
  any(),
  binary(),
  list(),
  binary(),
  binary(),
  boolean(),
  boolean(),
  boolean(),
  Price.t(),
  boolean(),
  ProductWeight.t(),
  ProductDimensions.t(),
  list(),
  map(),
  binary()
) :: ExSbapi.Product.t()

Builds a new ExSbapi.Product struct using the provided arguments.

Arguments

  • title - title of the product.
  • variations - a list of ExSbapi.ProductVariation structs
  • collections - a list of ExSbapi.ProductType structs
  • description - description of the product.
  • status - “0” or “1”
  • images - a list of images
  • ref - a reference string
  • language - language code ex. “en”
  • new - boolean, to indicate if product is new
  • on_sale - boolean, to indicate if product is on sale
  • same_price - boolean, to indicate if all product variations has the same price
  • price - a ExSbapi.Price struct (will apply to all variations)
  • same_weight_dimensions - boolean, to indicate if all product variations has the same dimensions and weight
  • weight - a ExSbapi.ProductWeight struct (will apply to all variations)
  • dimensions - a ExSbapi.ProductDimensions struct (will apply to all variations)
  • suggested_products - a list of suggested products
  • seo - a tupple containing seo fields
  • type - ex. “shop_builder_display”
Link to this function build_product_variation(sku, stock, price, dimensions \\ nil, weight \\ nil, status \\ "1", images \\ nil, options \\ nil, old_price \\ nil) View Source
build_product_variation(
  binary(),
  integer(),
  Price.t(),
  ProductDimensions.t(),
  ProductWeight.t(),
  binary(),
  list(),
  map(),
  Price.t()
) :: ExSbapi.ProductVariation.t()

Builds a new ExSbapi.ProductVariation struct using the provided arguments.

Arguments

Link to this function check_email(access_token, email, client \\ %{}) View Source
Link to this function create_image(website_url, access_token, imagename, imagedata, status \\ "1", format \\ "json") View Source
create_image(binary(), binary(), binary(), binary(), any(), binary()) ::
  {:ok, Response.t()} | {:error, Response.t()} | {:error, Error.t()}

Creates a image to the given website_url.

Arguments

  • imagename - name of the image.
  • imagedata - image in base64.
  • status - “0” (unpublished) or “1” (published).

Makes a POST request to the given website_url using the OAuth2.AccessToken.

Link to this function delete_custom_shipping(website_url, access_token, method_name) View Source
Link to this function delete_option(option_id, website_url, access_token) View Source
delete_option(integer(), binary(), binary()) ::
  {:ok, Response.t()} | {:error, Response.t()} | {:error, Error.t()}

Deletes the option with the given option_id from the given website_url.

Makes a DELETE request to the given website_url using the OAuth2.AccessToken

Link to this function delete_request(arg1, arg2) View Source
Link to this function generate_auto_login_link(user_uuid, destination_url, access_token, client \\ %{}) View Source
Link to this function get_address(user_id, website_url, access_token, format \\ "", option \\ "") View Source
Link to this function get_collections(website_url, access_token, fields \\ nil, filter \\ %{}, format \\ "json") View Source

Fetchs all product collections from the given website_url.

Makes a GET request to the given website_url using the OAuth2.AccessToken

Link to this function get_custom_shipping(website_url, access_token) View Source
Link to this function get_option(option_id, website_url, access_token, format \\ "json") View Source
get_option(integer(), binary(), binary(), binary()) ::
  {:ok, Response.t()} | {:error, Response.t()} | {:error, Error.t()}

Gets the option with the given option_id from the given website_url.

Makes a GET request to the given website_url using the OAuth2.AccessToken

Link to this function get_options(website_url, access_token, fields \\ nil, filter \\ %{}, format \\ "json") View Source

Fetchs all product options from the given website_url.

Makes a GET request to the given website_url using the OAuth2.AccessToken

Link to this function get_order(order_id, website_url, access_token, format \\ "json") View Source
Link to this function get_payload(your_hash_key, payload, sb_hash, format \\ "") View Source
Link to this function get_payment_options(order_id, website_url, access_token) View Source
Link to this function get_products(website_url, access_token, fields \\ nil, filter \\ %{}, format \\ "json") View Source

Fetchs all products from the given website_url.

Makes a GET request to the given website_url using the OAuth2.AccessToken

Link to this function get_profile_mobile_number(access_token, client \\ %{}) View Source
Link to this function get_restricted_mode(access_token, client \\ %{}) View Source
Link to this function get_roles(access_token, client \\ %{}) View Source
Link to this function get_sb_countries(website_url, access_token, format \\ "json") View Source
Link to this function get_shipping_options(order_id, website_url, access_token) View Source
Link to this function get_sublevel_menu_link(menu_id, website_url, access_token, format \\ "json") View Source
get_sublevel_menu_link(integer(), binary(), binary(), binary()) ::
  {:ok, Response.t()} | {:error, Response.t()} | {:error, Error.t()}

Gets the sublevel menu link with the given menu_id from the given website_url.

Makes a GET request to the given website_url using the OAuth2.AccessToken

Link to this function get_sublevel_menu_links(website_url, access_token, fields \\ nil, filter \\ %{}, format \\ "json") View Source

Fetchs all sublevel menu links from the given website_url.

Makes a GET request to the given website_url using the OAuth2.AccessToken

Link to this function get_subscribed_emails(access_token, client \\ %{}) View Source
Link to this function get_token!(provider, code, client) View Source
Link to this function list_of_events(access_token, client \\ %{}) View Source
Link to this function order_query(list_of_uuid, date, access_token, client \\ %{}) View Source

This function is expecting list_of_uuid,date, access_token and client

The format of date should be:

date: %{
  start: %{
    year: "2018",
    month: "4",
    day: "12"
  },
  end: %{
    year: "2018",
    month: "4",
    day: "20"
  }
}
Link to this function post_request(arg1, arg2) View Source
Link to this function product_bulk_operation(website_url, access_token, body, format \\ "json") View Source
product_bulk_operation(binary(), binary(), any(), binary()) ::
  {:ok, Response.t()} | {:error, Response.t()} | {:error, Error.t()}

Initiates a product bulk operation that can create, update or delete a set of products (up to 20 products) in a single request to the given website_url.

Makes a POST request to the given website_url using the OAuth2.AccessToken.

Link to this function product_redirections(status, access_token, client \\ %{}) View Source
Link to this function redirection_to_product(status, access_token, client) View Source
Link to this function refresh_token(refresh_token, client, params \\ [], headers \\ [], opts \\ []) View Source
Link to this function set_app_settings(website_url, access_token, body) View Source

Set app settings

Endpoint:

This function is being called from /lib/zaq_web/controllers/auth_controller.ex by callback/2

Parameters:

website_url::String , access_token::String, body::Map %{scripts: "", html: "", hash_key: ""}

Examples:

iex> set_app_settings(
  "http:\merhi.dev.shopbuilder.me", 
  "01a1f82c447c1ffc19f54a8174ae1b8e648cc864",
  %{hash_key: "5tQ4jHbQAqdfjI3cNEqoLAIChw6ZK2BI9tJR9omkzNCAFZS7odwcx+yC5xxTgt47wUg0iaoKuoRyClhU/3+okQ=="}
)
{:ok, %{"success": ["App settings has been updated."]}}
Link to this function set_profile_mobile_number(required, show_on_registration_form, access_token, client \\ %{}) View Source
Link to this function set_restricted_mode(restricted, mode, authorized_roles, access_token, client \\ %{}) View Source
Link to this function subscribe_email(event, endpoint, access_token, client \\ %{}) View Source
Link to this function subscribe_to_event(event, endpoint, access_token, client \\ %{}, object \\ "subscribe") View Source
Link to this function unsubscribe_email(endpoint, access_token, client \\ %{}) View Source
Link to this function unsubscribe_email_all(access_token, client \\ %{}) View Source
Link to this function unsubscribe_from_all_events(access_token, client \\ %{}, object \\ "unsubscribe") View Source
Link to this function unsubscribe_from_event(endpoint, access_token, client \\ %{}, object \\ "unsubscribe") View Source
Link to this function update_custom_shipping(website_url, access_token, body, method_name) View Source
Link to this function update_image(website_url, access_token, fid, imagedata, status \\ "1", format \\ "json") View Source
update_image(binary(), binary(), integer(), binary(), binary(), binary()) ::
  {:ok, Response.t()} | {:error, Response.t()} | {:error, Error.t()}

Updates a image to the given website_url.

Arguments

  • fid - image id.
  • filedata - image in base64.
  • status - “0” (unpublished) or “1” (published).

Makes a PUT request to the given website_url using the OAuth2.AccessToken.

Link to this function update_option(option_id, website_url, access_token, name, is_attribute \\ false, is_searchable \\ false, is_default_visible \\ false, show_as_button \\ false, facet_widget_type \\ "facetapi_checkbox_links", bundle_type \\ "shop_builder", format \\ "json") View Source

Updates a product option with the given option_id to the given website_url with the provided arguments.

Arguments

  • option_id - id of the option.
  • name - name of the option.
  • bundle_type - bundle type to which this option is available.
  • is_attribute - boolean, to indicate if this option is an attribute.
  • is_searchable - boolean, to indicate if this option should be added as a filter in the shop page.
  • is_default_visible - boolean, to indicate if this option should show when adding products.
  • show_as_button - boolean, to indicate if this option should show as a button in the product page.
  • facet_widget_type - string, provide the facet filter widget type.

Makes a PUT request to the given website_url using the OAuth2.AccessToken.

Link to this function update_sublevel_menu_link(website_url, access_token, menu_id, path, format \\ "json") View Source
update_sublevel_menu_link(binary(), binary(), binary(), binary(), binary()) ::
  {:ok, Response.t()} | {:error, Response.t()} | {:error, Error.t()}

Updates a sublevel menu link with the given menu_id to the given website_url.

Arguments

  • menu_id - sublevel menu link id.
  • link - sublevel menu link path.

Makes a PUT request to the given website_url using the OAuth2.AccessToken.