question

ojhatushar avatar image
ojhatushar asked Jacob Abrams commented

How to get open order from clover sdk

Hi

I am creating order from my application using below function:-

Order order = orderConnector.createOrder(new Order());

I want to ask below things.

How to get all orders which is open ? Can we get order state?

OrdersClover Android SDK
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jacob Abrams avatar image
Jacob Abrams answered Jacob Abrams commented

You can use the OrderContract in the clover-android-sdk:

https://github.com/clover/clover-android-sdk/blob/master/clover-android-sdk/src/main/java/com/clover/sdk/v3/order/OrderContract.java

Use the contract with ContentProvider#query

https://developer.android.com/reference/android/content/ContentResolver?hl=en#query(android.net.Uri,%20java.lang.String%5B%5D,%20java.lang.String,%20java.lang.String%5B%5D,%20java.lang.String)

The query should have the following params:

uri: OrdersContract.Summaries.contentUriWithAccount(...)

projection: null (or the specific columns you want)

selection: OrdersContract.Summaries.PAYMENT_STATE + " = ?"

selectionArgs: { "OPEN" }

sortOrder: OrderContract.Summaries.CREATED + " DESC"


You will get back a Cursor that you may iterate over and read the results. Our OrderPaidActivity example in clover-android-sdk has an example query using the OrderContract in it.

You should also read about content provider if you aren't familiar with it here: https://developer.android.com/guide/topics/providers/content-provider-basics

2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

Thanks Jacob. Very good to know. Do we have documentation on this?

0 Likes 0 ·
Jacob Abrams avatar image Jacob Abrams ♦♦ David Marginian ♦♦ commented ·

We need to improve documentation on our clover-android-sdk, especially regarding contracts.

Looking at the main javadoc front page located here https://clover.github.io/clover-android-sdk/ you will notice the following statement: "Searching for and displaying large amounts of data is best done through a content provider" followed by a link to the OrderContract javadocs which are quite minimal unfortunately.

0 Likes 0 ·
David Marginian avatar image
David Marginian Deactivated answered Jacob Abrams commented

I believe OrderConnector can retrieve a list of orders only by id. I think you will have to use the REST API to filter by state - https://docs.clover.com/clover-platform/reference#ordergetorders-2.

2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ojhatushar avatar image ojhatushar commented ·

Any another way, I want to get only open orders using clover sdk

0 Likes 0 ·
Jacob Abrams avatar image Jacob Abrams ♦♦ commented ·

Android apps running on Clover devices should avoid using the REST API, it's almost never necessary. Using the REST API from android apps is much slower and requires an active network connection but our goal is for nearly all functionality on our devices to work offline as well as online. Nearly all the data and functionality needed should be available in the clover-android-sdk.

0 Likes 0 ·

Welcome to the
Clover Developer Community