GithubHelp home page GithubHelp logo

fdk-client-python's Introduction

FDK Python

GitHub requirements.txt version GitHub Workflow Status GitHub Coverage Status

FDK client for python

Getting Started

Get started with the python Development SDK for Fynd Platform

Usage

pip install fdk-client-python

Using this method, you can import fdk-client-python like so:

from fdk_client.application.ApplicationClient import ApplicationClient
from fdk_client.application.ApplicationConfig import ApplicationConfig

Sample Usage - ApplicationClient

config = ApplicationConfig({
    "applicationID": "YOUR_APPLICATION_ID",
    "applicationToken": "YOUR_APPLICATION_TOKEN",
    "domain": "YOUR_DOMAIN"
})

applicationClient = ApplicationClient(config)

async def getProductDetails():
    try:
        product = await applicationClient.catalog.getProductDetailBySlug(slug="product-slug")
        print(product)
    except Exception as e:
        print(e)

getProductDetails()

Sample Usage - PlatformClient

from fdk_client.common.aiohttp_helper import AiohttpHelper
from fdk_client.platform.PlatformConfig import PlatformConfig
from fdk_client.platform.PlatformClient import PlatformClient
from fdk_client.common.utils import create_url_without_domain, get_headers_with_signature


async def setAccessToken(platformConfig, cookies):
    reqData = {
        "grant_type": "client_credentials",
        "client_id": platformConfig.apiKey,
        "client_secret": platformConfig.apiSecret
    }
    url = f"{platformConfig.domain}/service/panel/authentication/v1.0/company/{platformConfig.companyId}/oauth/token"
    url_without_domain = await create_url_without_domain(f"/service/panel/authentication/v1.0/company/{platformConfig.companyId}/oauth/token")
    headers = await get_headers_with_signature(platformConfig.domain, "post", url_without_domain, "", {}, reqData)
    res = await AiohttpHelper().aiohttp_request("POST", url, reqData, headers, cookies=cookies)
    return res["json"]

async def loginUser(platformConfig):
    skywarpURL = f"{platformConfig.domain}/service/panel/authentication/v1.0/auth/login/password"
    userData = {
        "username": "YOUR_USERNAME",
        "password": "YOUR_PASSWORD",
        "g-recaptcha-response": "_skip_"
    }
    url_without_domain = "/service/panel/authentication/v1.0/auth/login/password"
    headers = await get_headers_with_signature(platformConfig.domain, "post", url_without_domain, "", {}, userData)
    res = await AiohttpHelper().aiohttp_request("POST", skywarpURL, userData, headers)
    return res

try:
    platformConfig = PlatformConfig({
        "companyId": "YOUR_COMPANY_ID",
        "domain": "YOUR_DOMAIN",
        "apiKey": "YOUR_APIKEY",
        "apiSecret": "YOUR_APISECRET"
    })
    loginResponse = await loginUser(platformConfig)
    # print(loginResponse)
    tokenResponse = await setAccessToken(platformConfig, loginResponse["cookies"])
    # print(tokenResponse)
    await platformConfig.oauthClient.setToken(tokenResponse)
    platformClient = PlatformClient(platformConfig)
    res = await platformClient.lead.getTicket(id="YOUR_TICKET_ID")
    # use res
except Exception as e:
    print(e)

fdk-client-python's People

Contributors

jigardafda avatar nikhilmanapure avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.