Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Commit ccc196b

Browse files
author
Yang Fan
committed
First connect java sdk.
1 parent fe52dab commit ccc196b

File tree

164 files changed

+18343
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+18343
-0
lines changed

Diff for: .gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,13 @@
1010

1111
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
1212
hs_err_pid*
13+
14+
target
15+
build
16+
.gradle
17+
.settings
18+
.classpath
19+
.project
20+
git_push.sh
21+
build.sbt
22+
AndroidManifest.xml

Diff for: README.md

+213
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
# connect
2+
3+
## Requirements
4+
5+
Building the API client library requires [Maven](https://maven.apache.org/) to be installed.
6+
7+
## Installation
8+
9+
To install the API client library to your local Maven repository, simply execute:
10+
11+
```shell
12+
mvn install
13+
```
14+
15+
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
16+
17+
```shell
18+
mvn deploy
19+
```
20+
21+
Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information.
22+
23+
### Maven users
24+
25+
Add this dependency to your project's POM:
26+
27+
```xml
28+
<dependency>
29+
<groupId>com.squareup</groupId>
30+
<artifactId>connect</artifactId>
31+
<version>2.0.2</version>
32+
<scope>compile</scope>
33+
</dependency>
34+
```
35+
36+
### Gradle users
37+
38+
Add this dependency to your project's build file:
39+
40+
```groovy
41+
compile "com.squareup:connect:2.0.2"
42+
```
43+
44+
### Others
45+
46+
At first generate the JAR by executing:
47+
48+
mvn package
49+
50+
Then manually install the following JARs:
51+
52+
* target/connect-2.0.2.jar
53+
* target/lib/*.jar
54+
55+
## Getting Started
56+
57+
Please follow the [installation](#installation) instruction and execute the following Java code:
58+
59+
```java
60+
61+
import com.squareup.connect.*;
62+
import com.squareup.connect.auth.*;
63+
import com.squareup.connect.models.*;
64+
import com.squareup.connect.api.CheckoutApi;
65+
66+
import java.io.File;
67+
import java.util.*;
68+
69+
public class CheckoutApiExample {
70+
71+
public static void main(String[] args) {
72+
73+
CheckoutApi apiInstance = new CheckoutApi();
74+
String authorization = "authorization_example"; // String | The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
75+
String locationId = "locationId_example"; // String | The ID of the business location to associate the checkout with.
76+
CreateCheckoutRequest body = new CreateCheckoutRequest(); // CreateCheckoutRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
77+
try {
78+
CreateCheckoutResponse result = apiInstance.createCheckout(authorization, locationId, body);
79+
System.out.println(result);
80+
} catch (ApiException e) {
81+
System.err.println("Exception when calling CheckoutApi#createCheckout");
82+
e.printStackTrace();
83+
}
84+
}
85+
}
86+
87+
```
88+
89+
## Documentation for API Endpoints
90+
91+
All URIs are relative to *https://connect.squareup.com*
92+
93+
Class | Method | HTTP request | Description
94+
------------ | ------------- | ------------- | -------------
95+
*CheckoutApi* | [**createCheckout**](docs/CheckoutApi.md#createCheckout) | **POST** /v2/locations/{location_id}/checkouts | CreateCheckout
96+
*CustomerApi* | [**createCustomer**](docs/CustomerApi.md#createCustomer) | **POST** /v2/customers | CreateCustomer
97+
*CustomerApi* | [**deleteCustomer**](docs/CustomerApi.md#deleteCustomer) | **DELETE** /v2/customers/{customer_id} | DeleteCustomer
98+
*CustomerApi* | [**listCustomers**](docs/CustomerApi.md#listCustomers) | **GET** /v2/customers | ListCustomers
99+
*CustomerApi* | [**retrieveCustomer**](docs/CustomerApi.md#retrieveCustomer) | **GET** /v2/customers/{customer_id} | RetrieveCustomer
100+
*CustomerApi* | [**updateCustomer**](docs/CustomerApi.md#updateCustomer) | **PUT** /v2/customers/{customer_id} | UpdateCustomer
101+
*CustomerCardApi* | [**createCustomerCard**](docs/CustomerCardApi.md#createCustomerCard) | **POST** /v2/customers/{customer_id}/cards | CreateCustomerCard
102+
*CustomerCardApi* | [**deleteCustomerCard**](docs/CustomerCardApi.md#deleteCustomerCard) | **DELETE** /v2/customers/{customer_id}/cards/{card_id} | DeleteCustomerCard
103+
*LocationApi* | [**listLocations**](docs/LocationApi.md#listLocations) | **GET** /v2/locations | ListLocations
104+
*RefundApi* | [**createRefund**](docs/RefundApi.md#createRefund) | **POST** /v2/locations/{location_id}/transactions/{transaction_id}/refund | CreateRefund
105+
*RefundApi* | [**listRefunds**](docs/RefundApi.md#listRefunds) | **GET** /v2/locations/{location_id}/refunds | ListRefunds
106+
*TransactionApi* | [**captureTransaction**](docs/TransactionApi.md#captureTransaction) | **POST** /v2/locations/{location_id}/transactions/{transaction_id}/capture | CaptureTransaction
107+
*TransactionApi* | [**charge**](docs/TransactionApi.md#charge) | **POST** /v2/locations/{location_id}/transactions | Charge
108+
*TransactionApi* | [**listTransactions**](docs/TransactionApi.md#listTransactions) | **GET** /v2/locations/{location_id}/transactions | ListTransactions
109+
*TransactionApi* | [**retrieveTransaction**](docs/TransactionApi.md#retrieveTransaction) | **GET** /v2/locations/{location_id}/transactions/{transaction_id} | RetrieveTransaction
110+
*TransactionApi* | [**voidTransaction**](docs/TransactionApi.md#voidTransaction) | **POST** /v2/locations/{location_id}/transactions/{transaction_id}/void | VoidTransaction
111+
112+
113+
## Documentation for Models
114+
115+
- [Address](docs/Address.md)
116+
- [CaptureTransactionRequest](docs/CaptureTransactionRequest.md)
117+
- [CaptureTransactionResponse](docs/CaptureTransactionResponse.md)
118+
- [Card](docs/Card.md)
119+
- [CardBrand](docs/CardBrand.md)
120+
- [ChargeRequest](docs/ChargeRequest.md)
121+
- [ChargeResponse](docs/ChargeResponse.md)
122+
- [Checkout](docs/Checkout.md)
123+
- [Country](docs/Country.md)
124+
- [CreateCheckoutRequest](docs/CreateCheckoutRequest.md)
125+
- [CreateCheckoutResponse](docs/CreateCheckoutResponse.md)
126+
- [CreateCustomerCardRequest](docs/CreateCustomerCardRequest.md)
127+
- [CreateCustomerCardResponse](docs/CreateCustomerCardResponse.md)
128+
- [CreateCustomerRequest](docs/CreateCustomerRequest.md)
129+
- [CreateCustomerResponse](docs/CreateCustomerResponse.md)
130+
- [CreateOrderRequest](docs/CreateOrderRequest.md)
131+
- [CreateOrderRequestLineItem](docs/CreateOrderRequestLineItem.md)
132+
- [CreateOrderRequestOrder](docs/CreateOrderRequestOrder.md)
133+
- [CreateRefundRequest](docs/CreateRefundRequest.md)
134+
- [CreateRefundResponse](docs/CreateRefundResponse.md)
135+
- [Currency](docs/Currency.md)
136+
- [Customer](docs/Customer.md)
137+
- [CustomerGroupInfo](docs/CustomerGroupInfo.md)
138+
- [CustomerPreferences](docs/CustomerPreferences.md)
139+
- [DeleteCustomerCardRequest](docs/DeleteCustomerCardRequest.md)
140+
- [DeleteCustomerCardResponse](docs/DeleteCustomerCardResponse.md)
141+
- [DeleteCustomerRequest](docs/DeleteCustomerRequest.md)
142+
- [DeleteCustomerResponse](docs/DeleteCustomerResponse.md)
143+
- [Error](docs/Error.md)
144+
- [ErrorCategory](docs/ErrorCategory.md)
145+
- [ErrorCode](docs/ErrorCode.md)
146+
- [ListCustomersRequest](docs/ListCustomersRequest.md)
147+
- [ListCustomersResponse](docs/ListCustomersResponse.md)
148+
- [ListLocationsRequest](docs/ListLocationsRequest.md)
149+
- [ListLocationsResponse](docs/ListLocationsResponse.md)
150+
- [ListRefundsRequest](docs/ListRefundsRequest.md)
151+
- [ListRefundsResponse](docs/ListRefundsResponse.md)
152+
- [ListTransactionsRequest](docs/ListTransactionsRequest.md)
153+
- [ListTransactionsResponse](docs/ListTransactionsResponse.md)
154+
- [Location](docs/Location.md)
155+
- [LocationCapability](docs/LocationCapability.md)
156+
- [Money](docs/Money.md)
157+
- [Order](docs/Order.md)
158+
- [OrderLineItem](docs/OrderLineItem.md)
159+
- [Refund](docs/Refund.md)
160+
- [RefundStatus](docs/RefundStatus.md)
161+
- [RetrieveCustomerRequest](docs/RetrieveCustomerRequest.md)
162+
- [RetrieveCustomerResponse](docs/RetrieveCustomerResponse.md)
163+
- [RetrieveTransactionRequest](docs/RetrieveTransactionRequest.md)
164+
- [RetrieveTransactionResponse](docs/RetrieveTransactionResponse.md)
165+
- [SortOrder](docs/SortOrder.md)
166+
- [Tender](docs/Tender.md)
167+
- [TenderCardDetails](docs/TenderCardDetails.md)
168+
- [TenderCardDetailsEntryMethod](docs/TenderCardDetailsEntryMethod.md)
169+
- [TenderCardDetailsStatus](docs/TenderCardDetailsStatus.md)
170+
- [TenderCashDetails](docs/TenderCashDetails.md)
171+
- [TenderType](docs/TenderType.md)
172+
- [Transaction](docs/Transaction.md)
173+
- [TransactionProduct](docs/TransactionProduct.md)
174+
- [UpdateCustomerRequest](docs/UpdateCustomerRequest.md)
175+
- [UpdateCustomerResponse](docs/UpdateCustomerResponse.md)
176+
- [VoidTransactionRequest](docs/VoidTransactionRequest.md)
177+
- [VoidTransactionResponse](docs/VoidTransactionResponse.md)
178+
179+
180+
## Documentation for Authorization
181+
182+
Authentication schemes defined for the API:
183+
### oauth2
184+
185+
- **Type**: OAuth
186+
- **Flow**: accessCode
187+
- **Authorization URL**: https://connect.squareup.com/oauth2/authorize?&lt;PARAMETERS&gt;
188+
- **Scopes**:
189+
- MERCHANT_PROFILE_READ: GET endpoints related to a merchant&#39;s business and location entities. Almost all Connect API applications need this permission in order to obtain a merchant&#39;s location IDs
190+
- PAYMENTS_READ: GET endpoints related to transactions and refunds
191+
- PAYMENTS_WRITE: POST, PUT, and DELETE endpoints related to transactions and refunds. E-commerce applications must request this permission
192+
- CUSTOMERS_READ: GET endpoints related to customer management
193+
- CUSTOMERS_WRITE: POST, PUT, and DELETE endpoints related to customer management
194+
- SETTLEMENTS_READ: GET endpoints related to settlements (deposits)
195+
- BANK_ACCOUNTS_READ: GET endpoints related to a merchant&#39;s bank accounts
196+
- ITEMS_READ: GET endpoints related to a merchant&#39;s item library
197+
- ITEMS_WRITE: POST, PUT, and DELETE endpoints related to a merchant&#39;s item library
198+
- ORDERS_READ: GET endpoints related to a merchant&#39;s Square online store.
199+
- ORDERS_WRITE: POST, PUT, and DELETE endpoints related to a merchant&#39;s Square online store
200+
- EMPLOYEES_READ: GET endpoints related to employee management
201+
- EMPLOYEES_WRITE: POST, PUT, and DELETE endpoints related to employee management
202+
- TIMECARDS_READ: GET endpoints related to employee timecards
203+
- TIMECARDS_WRITE: POST, PUT, and DELETE endpoints related to employee timecards
204+
205+
206+
## Recommendation
207+
208+
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
209+
210+
## Author
211+
212+
213+

Diff for: build.gradle

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
apply plugin: 'idea'
2+
apply plugin: 'eclipse'
3+
4+
group = 'com.squareup'
5+
version = '2.0.2'
6+
7+
buildscript {
8+
repositories {
9+
jcenter()
10+
}
11+
dependencies {
12+
classpath 'com.android.tools.build:gradle:1.5.+'
13+
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
14+
}
15+
}
16+
17+
repositories {
18+
jcenter()
19+
}
20+
21+
22+
if(hasProperty('target') && target == 'android') {
23+
24+
apply plugin: 'com.android.library'
25+
apply plugin: 'com.github.dcendents.android-maven'
26+
27+
android {
28+
compileSdkVersion 23
29+
buildToolsVersion '23.0.2'
30+
defaultConfig {
31+
minSdkVersion 14
32+
targetSdkVersion 23
33+
}
34+
compileOptions {
35+
sourceCompatibility JavaVersion.VERSION_1_8
36+
targetCompatibility JavaVersion.VERSION_1_8
37+
}
38+
39+
// Rename the aar correctly
40+
libraryVariants.all { variant ->
41+
variant.outputs.each { output ->
42+
def outputFile = output.outputFile
43+
if (outputFile != null && outputFile.name.endsWith('.aar')) {
44+
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
45+
output.outputFile = new File(outputFile.parent, fileName)
46+
}
47+
}
48+
}
49+
50+
dependencies {
51+
provided 'javax.annotation:jsr250-api:1.0'
52+
}
53+
}
54+
55+
afterEvaluate {
56+
android.libraryVariants.all { variant ->
57+
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
58+
task.description = "Create jar artifact for ${variant.name}"
59+
task.dependsOn variant.javaCompile
60+
task.from variant.javaCompile.destinationDir
61+
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
62+
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
63+
artifacts.add('archives', task);
64+
}
65+
}
66+
67+
task sourcesJar(type: Jar) {
68+
from android.sourceSets.main.java.srcDirs
69+
classifier = 'sources'
70+
}
71+
72+
artifacts {
73+
archives sourcesJar
74+
}
75+
76+
} else {
77+
78+
apply plugin: 'java'
79+
apply plugin: 'maven'
80+
81+
sourceCompatibility = JavaVersion.VERSION_1_8
82+
targetCompatibility = JavaVersion.VERSION_1_8
83+
84+
install {
85+
repositories.mavenInstaller {
86+
pom.artifactId = 'connect'
87+
}
88+
}
89+
90+
task execute(type:JavaExec) {
91+
main = System.getProperty('mainClass')
92+
classpath = sourceSets.main.runtimeClasspath
93+
}
94+
}
95+
96+
ext {
97+
swagger_annotations_version = "1.5.8"
98+
jackson_version = "2.7.5"
99+
jersey_version = "1.19.1"
100+
jodatime_version = "2.9.4"
101+
junit_version = "4.12"
102+
}
103+
104+
dependencies {
105+
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
106+
compile "com.sun.jersey:jersey-client:$jersey_version"
107+
compile "com.sun.jersey.contribs:jersey-multipart:$jersey_version"
108+
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
109+
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
110+
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
111+
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
112+
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
113+
compile "com.brsanthu:migbase64:2.2"
114+
testCompile "junit:junit:$junit_version"
115+
}

0 commit comments

Comments
 (0)