GithubHelp home page GithubHelp logo

ecwid-java-api-client's Introduction

Ecwid java api client library

API documentation: https://api-docs.ecwid.com/reference/overview

Configure client library:

You can test this api client library on you local storage. For this you need to copy test/resources/test.properties.sample renamed to test.properties and configure it

For example: test.properties

storeId=2
apiToken=secret_4T6z...
apiHost=app.local.ecwid.com
apiPort=8443

Examples

Simple example:

val apiClient = ApiClient.create(
		apiServerDomain = ApiServerDomain(),
		storeCredentials = ApiStoreCredentials(
				storeId = 1003,
				apiToken = "secret_mysecuretoken"),
		httpTransport = ApacheCommonsHttpClientTransport(),
		jsonTransformerProvider = GsonTransformerProvider()

val customer = apiClient.getCustomerDetails(CustomerDetailsRequest(customerId = 1))
println("api/v3 customer: $customer")

Batch api example:

val apiClient = ApiClient.create(
		apiServerDomain = ApiServerDomain(),
		storeCredentials = ApiStoreCredentials(
				storeId = 1003,
				apiToken = "secret_mysecuretoken"),
		httpTransport = ApacheCommonsHttpClientTransport(),
		jsonTransformerProvider = GsonTransformerProvider()

val requestsForBatch = listOf(CustomerDetailsRequest(1), CustomerDetailsRequest(2))
val batch = apiClient.createBatch(CreateBatchRequest(requestsForBatch, stopOnFirstFailure = true))

while (true) {
	val typedBatch = apiClient.getTypedBatch(GetEscapedBatchRequest(batch.ticket))
	if (typedBatch.status != BatchStatus.COMPLETED) {
		TimeUnit.SECONDS.sleep(2)
		continue
	}
	val customers = typedBatch.responses.orEmpty()
			.map { it.toTypedResponse(FetchedCustomer::class.java) }
			.mapNotNull { if (it is TypedBatchResponse.Ok<FetchedCustomer>) it.value else null }
	val errors = typedBatch.responses.orEmpty()
			.map { it.toTypedResponse(FetchedCustomer::class.java) }
			.mapNotNull { if (it !is TypedBatchResponse.Ok<FetchedCustomer>) it.toString() else null }
	println("api/v3 customers: ${customers.joinToString { it.id.toString() }}, errors: ${errors.joinToString()}")
	break;
}

ecwid-java-api-client's People

Contributors

aleskarova avatar alexeyyy avatar alexis2004 avatar alf-ecwid avatar alxzoomer avatar arakaru avatar atoktarev avatar bormanecwid avatar cesarfromecwid avatar chesterecwid avatar ecwidares avatar garnet-ecwid avatar hanna-ecwid avatar juvirez avatar kitty-ecwid avatar kurguzov avatar mplain avatar or4ng3 avatar sergey-elmanov avatar sinabz-lspd avatar skip-ecwid avatar soer-ecwid avatar sylorei avatar tobi-ecwid avatar turchenkoalex avatar warlock-ecwid avatar weden-ecwid avatar winrokru avatar xxxrazorxxx avatar zenon-ecwid 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.