Module sap.commerce.webservices

ballerinax/sap.commerce.webservices Ballerina library

0.9.0

Overview

SAP Commerce Cloud is a comprehensive e-commerce platform that enables businesses to deliver personalized, omnichannel shopping experiences across all touchpoints, from web and mobile to social and in-store interactions.

The ballerinax/sap.commerce.webservices package offers APIs to connect and interact with SAP Commerce Cloud API endpoints, specifically based on SAP Commerce Web Services API v2.

Setup guide

To use the SAP Commerce Web Services connector, you must have access to SAP Commerce Cloud (formerly SAP Hybris) through a valid SAP account and configure OAuth2 authentication credentials. If you do not have an SAP account, you can sign up for one here and explore SAP Commerce Cloud solutions at the SAP Commerce Cloud portal.

Step 1: Create an SAP Account and Access SAP Commerce Cloud

  1. Navigate to the SAP website and sign up for an account or log in if you already have one.

  2. Ensure you have access to SAP Commerce Cloud, which typically requires a licensed subscription or access through SAP's cloud platform services.

Step 2: Configure OAuth2 Client Credentials

  1. Log in to your SAP Commerce Cloud administration console (Backoffice or HAC - Hybris Administration Console).

  2. Navigate to System > OAuth > OAuth Client Details or access the OAuth configuration through the Platform > Configuration menu.

  3. Create a new OAuth client or modify an existing one by providing the necessary client ID and client secret for your application.

  4. Configure the appropriate scopes and grant types (typically "client_credentials" for API access) based on your integration requirements.

Tip: You must copy and store the client secret somewhere safe. It won't be visible again in your configuration settings for security reasons.

Quickstart

To use the SAP Commerce Web Services connector in your Ballerina application, update the .bal file as follows:

Step 1: Import the module

Copy
import ballerina/oauth2;
import ballerinax/sap.commerce.webservices as sapcommerce;

Step 2: Instantiate a new connector

  1. Create a Config.toml file with your credentials:
Copy
clientId = "<Your_Client_Id>"
clientSecret = "<Your_Client_Secret>"
refreshToken = "<Your_Refresh_Token>"
  1. Create a sapcommerce:ConnectionConfig and initialize the client:
Copy
configurable string clientId = ?;
configurable string clientSecret = ?;
configurable string refreshToken = ?;

final sapcommerce:Client sapcommerceClient = check new({
    auth: {
        clientId,
        clientSecret,
        refreshToken
    }
});

Step 3: Invoke the connector operation

Now, utilize the available connector operations.

Create a new cost center

Copy
public function main() returns error? {
    sapcommerce:B2BCostCenter newCostCenter = {
        code: "CC001",
        name: "Marketing Cost Center",
        activeFlag: true,
        currency: {
            isocode: "USD",
            name: "US Dollar"
        }
    };

    sapcommerce:B2BCostCenter response = check sapcommerceClient->createCostCenter("electronics", newCostCenter);
}

Step 4: Run the Ballerina application

Copy
bal run

Examples

The sap.commerce.webservices connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering the following use cases:

  1. Procurement cost center setup - Demonstrates how to configure and manage procurement cost centers using the SAP Commerce Web Services connector.
  2. Catalog inventory management - Illustrates managing product catalogs and inventory levels through SAP Commerce Web Services.
  3. Support ticket management - Shows how to create, update, and track customer support tickets using the connector.
  4. Customer service workflow - Demonstrates automating customer service processes and workflows through SAP Commerce Web Services.

Import

import ballerinax/sap.commerce.webservices;Copy

Other versions

0.9.0

Metadata

Released date: 4 days ago

Version: 0.9.0

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.13.0

GraalVM compatible: Yes


Pull count

Total: 0

Current verison: 0


Weekly downloads


Source repository


Keywords

category/connector

vendor/sap

domain/commerce

area/integration

protocol/rest


Contributors