diff --git a/README.md b/README.md index 51421e8..6f63e81 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ - Java 1.6 or Later +## Dependencies +1. Scribe OAuth Library » 1.3.7 [Link](https://mvnrepository.com/artifact/org.scribe/scribe) +2. org.json (JSON in Java) » 20171018 [Link](https://mvnrepository.com/artifact/org.json/json) + ## Usage import com.maxcdn.MaxCDN; import com.maxcdn.MaxCDNObject; @@ -12,7 +16,11 @@ //Class construction MaxCDN api = new MaxCDN(YOUR_ALIAS ,YOUR_CONSUMER_KEY,YOUR_CONSUMER_SECRET); //Performing a GET request + try { MaxCDNObject data = api.get("/account.json"); + } catch(Exception e){ + e.printStackTrace(); + } ## Advanced Usage This section describes how to perform PUT and POST requests. diff --git a/doc/allclasses-frame.html b/doc/allclasses-frame.html new file mode 100644 index 0000000..f22074e --- /dev/null +++ b/doc/allclasses-frame.html @@ -0,0 +1,25 @@ + + + + + +All Classes + + + + + +

All Classes

+
+ +
+ + diff --git a/doc/allclasses-noframe.html b/doc/allclasses-noframe.html new file mode 100644 index 0000000..1a7cc12 --- /dev/null +++ b/doc/allclasses-noframe.html @@ -0,0 +1,25 @@ + + + + + +All Classes + + + + + +

All Classes

+
+ +
+ + diff --git a/doc/com/maxcdn/Console.html b/doc/com/maxcdn/Console.html new file mode 100644 index 0000000..dfd7106 --- /dev/null +++ b/doc/com/maxcdn/Console.html @@ -0,0 +1,307 @@ + + + + + +Console + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
com.maxcdn
+

Class Console

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/MaxCDN.html b/doc/com/maxcdn/MaxCDN.html new file mode 100644 index 0000000..c99d475 --- /dev/null +++ b/doc/com/maxcdn/MaxCDN.html @@ -0,0 +1,720 @@ + + + + + +MaxCDN + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
com.maxcdn
+

Class MaxCDN

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/MaxCDNApi.html b/doc/com/maxcdn/MaxCDNApi.html new file mode 100644 index 0000000..75c051e --- /dev/null +++ b/doc/com/maxcdn/MaxCDNApi.html @@ -0,0 +1,399 @@ + + + + + +MaxCDNApi + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
com.maxcdn
+

Class MaxCDNApi

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/MaxCDNException.html b/doc/com/maxcdn/MaxCDNException.html new file mode 100644 index 0000000..768e541 --- /dev/null +++ b/doc/com/maxcdn/MaxCDNException.html @@ -0,0 +1,262 @@ + + + + + +MaxCDNException + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
com.maxcdn
+

Class MaxCDNException

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/MaxCDNObject.html b/doc/com/maxcdn/MaxCDNObject.html new file mode 100644 index 0000000..297bbe7 --- /dev/null +++ b/doc/com/maxcdn/MaxCDNObject.html @@ -0,0 +1,517 @@ + + + + + +MaxCDNObject + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
com.maxcdn
+

Class MaxCDNObject

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/MaxCDNRequest.html b/doc/com/maxcdn/MaxCDNRequest.html new file mode 100644 index 0000000..75db186 --- /dev/null +++ b/doc/com/maxcdn/MaxCDNRequest.html @@ -0,0 +1,375 @@ + + + + + +MaxCDNRequest + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
com.maxcdn
+

Class MaxCDNRequest

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/class-use/Console.html b/doc/com/maxcdn/class-use/Console.html new file mode 100644 index 0000000..e69b0d0 --- /dev/null +++ b/doc/com/maxcdn/class-use/Console.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class com.maxcdn.Console + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Class
com.maxcdn.Console

+
+
No usage of com.maxcdn.Console
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/class-use/MaxCDN.html b/doc/com/maxcdn/class-use/MaxCDN.html new file mode 100644 index 0000000..e8f0647 --- /dev/null +++ b/doc/com/maxcdn/class-use/MaxCDN.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class com.maxcdn.MaxCDN + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Class
com.maxcdn.MaxCDN

+
+
No usage of com.maxcdn.MaxCDN
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/class-use/MaxCDNApi.html b/doc/com/maxcdn/class-use/MaxCDNApi.html new file mode 100644 index 0000000..cb5cd40 --- /dev/null +++ b/doc/com/maxcdn/class-use/MaxCDNApi.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class com.maxcdn.MaxCDNApi + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Class
com.maxcdn.MaxCDNApi

+
+
No usage of com.maxcdn.MaxCDNApi
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/class-use/MaxCDNException.html b/doc/com/maxcdn/class-use/MaxCDNException.html new file mode 100644 index 0000000..45cfe18 --- /dev/null +++ b/doc/com/maxcdn/class-use/MaxCDNException.html @@ -0,0 +1,165 @@ + + + + + +Uses of Class com.maxcdn.MaxCDNException + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Class
com.maxcdn.MaxCDNException

+
+
+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/class-use/MaxCDNObject.html b/doc/com/maxcdn/class-use/MaxCDNObject.html new file mode 100644 index 0000000..b5e3a7d --- /dev/null +++ b/doc/com/maxcdn/class-use/MaxCDNObject.html @@ -0,0 +1,227 @@ + + + + + +Uses of Class com.maxcdn.MaxCDNObject + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Class
com.maxcdn.MaxCDNObject

+
+
+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/class-use/MaxCDNRequest.html b/doc/com/maxcdn/class-use/MaxCDNRequest.html new file mode 100644 index 0000000..be93ad3 --- /dev/null +++ b/doc/com/maxcdn/class-use/MaxCDNRequest.html @@ -0,0 +1,218 @@ + + + + + +Uses of Class com.maxcdn.MaxCDNRequest + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Class
com.maxcdn.MaxCDNRequest

+
+
+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/package-frame.html b/doc/com/maxcdn/package-frame.html new file mode 100644 index 0000000..ebd93a0 --- /dev/null +++ b/doc/com/maxcdn/package-frame.html @@ -0,0 +1,28 @@ + + + + + +com.maxcdn + + + + + +

com.maxcdn

+
+

Classes

+ +

Exceptions

+ +
+ + diff --git a/doc/com/maxcdn/package-summary.html b/doc/com/maxcdn/package-summary.html new file mode 100644 index 0000000..0f27f00 --- /dev/null +++ b/doc/com/maxcdn/package-summary.html @@ -0,0 +1,173 @@ + + + + + +com.maxcdn + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Package com.maxcdn

+
+
+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/package-tree.html b/doc/com/maxcdn/package-tree.html new file mode 100644 index 0000000..b823526 --- /dev/null +++ b/doc/com/maxcdn/package-tree.html @@ -0,0 +1,161 @@ + + + + + +com.maxcdn Class Hierarchy + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Hierarchy For Package com.maxcdn

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/com/maxcdn/package-use.html b/doc/com/maxcdn/package-use.html new file mode 100644 index 0000000..26e1647 --- /dev/null +++ b/doc/com/maxcdn/package-use.html @@ -0,0 +1,163 @@ + + + + + +Uses of Package com.maxcdn + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Package
com.maxcdn

+
+
+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/constant-values.html b/doc/constant-values.html new file mode 100644 index 0000000..707e2c4 --- /dev/null +++ b/doc/constant-values.html @@ -0,0 +1,167 @@ + + + + + +Constant Field Values + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Constant Field Values

+

Contents

+ +
+
+ + +

com.maxcdn.*

+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/deprecated-list.html b/doc/deprecated-list.html new file mode 100644 index 0000000..ea8d4c8 --- /dev/null +++ b/doc/deprecated-list.html @@ -0,0 +1,124 @@ + + + + + +Deprecated List + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/help-doc.html b/doc/help-doc.html new file mode 100644 index 0000000..25718c2 --- /dev/null +++ b/doc/help-doc.html @@ -0,0 +1,229 @@ + + + + + +API Help + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+ +This help file applies to API documentation generated using the standard doclet.
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-1.html b/doc/index-files/index-1.html new file mode 100644 index 0000000..84ff7af --- /dev/null +++ b/doc/index-files/index-1.html @@ -0,0 +1,145 @@ + + + + + +A-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

A

+
+
ACCESS_TOKEN_RESOURCE - Static variable in class com.maxcdn.MaxCDNApi
+
 
+
alias - Variable in class com.maxcdn.MaxCDN
+
+
Instance's API alias.
+
+
ApiDemo - Class in tests.tests
+
 
+
ApiDemo() - Constructor for class tests.tests.ApiDemo
+
 
+
append(String, Object) - Method in class com.maxcdn.MaxCDNObject
+
+
Set/Add key and object pair.
+
+
append(String, Object) - Method in class com.maxcdn.MaxCDNRequest
+
 
+
AUTHORIZE_URL - Static variable in class com.maxcdn.MaxCDNApi
+
 
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-10.html b/doc/index-files/index-10.html new file mode 100644 index 0000000..53ad301 --- /dev/null +++ b/doc/index-files/index-10.html @@ -0,0 +1,137 @@ + + + + + +R-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

R

+
+
request(String, Verb, MaxCDNRequest) - Method in class com.maxcdn.MaxCDN
+
+
Perform a request wih a custom verb.
+
+
request(String, Verb, MaxCDNRequest, Token) - Method in class com.maxcdn.MaxCDN
+
+
Perform a request wih a custom verb and access token.
+
+
REQUEST_TOKEN_RESOURCE - Static variable in class com.maxcdn.MaxCDNApi
+
 
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-11.html b/doc/index-files/index-11.html new file mode 100644 index 0000000..e3ff923 --- /dev/null +++ b/doc/index-files/index-11.html @@ -0,0 +1,137 @@ + + + + + +S-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

S

+
+
secret - Variable in class com.maxcdn.MaxCDN
+
+
Instance's API secret.
+
+
setToken(Token) - Method in class com.maxcdn.MaxCDN
+
+
Set access token
+
+
shoudlog - Static variable in class com.maxcdn.Console
+
 
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-12.html b/doc/index-files/index-12.html new file mode 100644 index 0000000..f5fa5b9 --- /dev/null +++ b/doc/index-files/index-12.html @@ -0,0 +1,133 @@ + + + + + +T-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

T

+
+
tests.tests - package tests.tests
+
 
+
token_stored - Variable in class com.maxcdn.MaxCDN
+
+
Access token of instance.
+
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-13.html b/doc/index-files/index-13.html new file mode 100644 index 0000000..c49e739 --- /dev/null +++ b/doc/index-files/index-13.html @@ -0,0 +1,131 @@ + + + + + +_-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

_

+
+
_request(String, Verb, MaxCDNRequest) - Method in class com.maxcdn.MaxCDN
+
 
+
_request(String, Verb, MaxCDNRequest, Token) - Method in class com.maxcdn.MaxCDN
+
 
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-2.html b/doc/index-files/index-2.html new file mode 100644 index 0000000..481825c --- /dev/null +++ b/doc/index-files/index-2.html @@ -0,0 +1,137 @@ + + + + + +C-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

C

+
+
code - Variable in class com.maxcdn.MaxCDNObject
+
+
Code of request.
+
+
com.maxcdn - package com.maxcdn
+
 
+
Console - Class in com.maxcdn
+
 
+
Console() - Constructor for class com.maxcdn.Console
+
 
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-3.html b/doc/index-files/index-3.html new file mode 100644 index 0000000..a68b56e --- /dev/null +++ b/doc/index-files/index-3.html @@ -0,0 +1,131 @@ + + + + + +D-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

D

+
+
delete(String) - Method in class com.maxcdn.MaxCDN
+
+
Perform a request with verb DELETE to specified endpoint.
+
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-4.html b/doc/index-files/index-4.html new file mode 100644 index 0000000..c6a4b62 --- /dev/null +++ b/doc/index-files/index-4.html @@ -0,0 +1,131 @@ + + + + + +E-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

E

+
+
error - Variable in class com.maxcdn.MaxCDNObject
+
+
Specifies if request has error.
+
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-5.html b/doc/index-files/index-5.html new file mode 100644 index 0000000..41b890a --- /dev/null +++ b/doc/index-files/index-5.html @@ -0,0 +1,159 @@ + + + + + +G-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

G

+
+
get(String) - Method in class com.maxcdn.MaxCDN
+
+
Perform a request with verb GET to specified endpoint.
+
+
getAccessToken(Token, String) - Method in class com.maxcdn.MaxCDN
+
+
Get access token from MaxCDN.
+
+
getAccessTokenEndpoint() - Method in class com.maxcdn.MaxCDNApi
+
 
+
getArray(String) - Method in class com.maxcdn.MaxCDNObject
+
 
+
getAuthorizationUrl(Token) - Method in class com.maxcdn.MaxCDNApi
+
 
+
getAuthUrl(Token) - Method in class com.maxcdn.MaxCDN
+
+
Perform a request with verb PUT to specified endpoint.
+
+
getErrorMessage() - Method in class com.maxcdn.MaxCDNObject
+
 
+
getJson(String) - Method in class com.maxcdn.MaxCDNObject
+
 
+
getNumber(String) - Method in class com.maxcdn.MaxCDNObject
+
 
+
getRequestToken() - Method in class com.maxcdn.MaxCDN
+
+
Generate a request token.
+
+
getRequestTokenEndpoint() - Method in class com.maxcdn.MaxCDNApi
+
 
+
getString(String) - Method in class com.maxcdn.MaxCDNObject
+
 
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-6.html b/doc/index-files/index-6.html new file mode 100644 index 0000000..16f92b3 --- /dev/null +++ b/doc/index-files/index-6.html @@ -0,0 +1,131 @@ + + + + + +K-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

K

+
+
key - Variable in class com.maxcdn.MaxCDN
+
+
Instance's API key.
+
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-7.html b/doc/index-files/index-7.html new file mode 100644 index 0000000..cd3d42c --- /dev/null +++ b/doc/index-files/index-7.html @@ -0,0 +1,129 @@ + + + + + +L-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

L

+
+
log(Object) - Static method in class com.maxcdn.Console
+
 
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-8.html b/doc/index-files/index-8.html new file mode 100644 index 0000000..7f60d8c --- /dev/null +++ b/doc/index-files/index-8.html @@ -0,0 +1,169 @@ + + + + + +M-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

M

+
+
main(String[]) - Static method in class tests.tests.ApiDemo
+
 
+
MaxCDN - Class in com.maxcdn
+
 
+
MaxCDN(String, String, String) - Constructor for class com.maxcdn.MaxCDN
+
+
Initialize client without API access token.
+
+
MaxCDN(String, String, String, Token) - Constructor for class com.maxcdn.MaxCDN
+
+
Initialize client with API token.
+
+
MaxCDNApi - Class in com.maxcdn
+
 
+
MaxCDNApi() - Constructor for class com.maxcdn.MaxCDNApi
+
 
+
MaxCDNException - Exception in com.maxcdn
+
 
+
MaxCDNException(String) - Constructor for exception com.maxcdn.MaxCDNException
+
 
+
MaxCDNObject - Class in com.maxcdn
+
 
+
MaxCDNObject() - Constructor for class com.maxcdn.MaxCDNObject
+
 
+
MaxCDNObject(String) - Constructor for class com.maxcdn.MaxCDNObject
+
 
+
MaxCDNObject(String, Object) - Constructor for class com.maxcdn.MaxCDNObject
+
 
+
MaxCDNObject(Object) - Constructor for class com.maxcdn.MaxCDNObject
+
 
+
MaxCDNRequest - Class in com.maxcdn
+
 
+
MaxCDNRequest() - Constructor for class com.maxcdn.MaxCDNRequest
+
 
+
MaxCDNRequest(String) - Constructor for class com.maxcdn.MaxCDNRequest
+
 
+
MaxCDNRequest(String, Object) - Constructor for class com.maxcdn.MaxCDNRequest
+
 
+
MaxCDNrws_url - Variable in class com.maxcdn.MaxCDN
+
+
MaxCDN RWS URL
+
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index-files/index-9.html b/doc/index-files/index-9.html new file mode 100644 index 0000000..b30926c --- /dev/null +++ b/doc/index-files/index-9.html @@ -0,0 +1,135 @@ + + + + + +P-Index + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
A C D E G K L M P R S T _  + + +

P

+
+
post(String, MaxCDNRequest) - Method in class com.maxcdn.MaxCDN
+
+
Perform a request with verb POST to specified endpoint.
+
+
put(String, MaxCDNRequest) - Method in class com.maxcdn.MaxCDN
+
+
Perform a request with verb PUT to specified endpoint.
+
+
+A C D E G K L M P R S T _ 
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 0000000..776d191 --- /dev/null +++ b/doc/index.html @@ -0,0 +1,74 @@ + + + + + +Generated Documentation (Untitled) + + + + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> + + + diff --git a/doc/overview-frame.html b/doc/overview-frame.html new file mode 100644 index 0000000..9d60f2f --- /dev/null +++ b/doc/overview-frame.html @@ -0,0 +1,22 @@ + + + + + +Overview List + + + + + +
All Classes
+
+

Packages

+ +
+

 

+ + diff --git a/doc/overview-summary.html b/doc/overview-summary.html new file mode 100644 index 0000000..2f02941 --- /dev/null +++ b/doc/overview-summary.html @@ -0,0 +1,142 @@ + + + + + +Overview + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

MaxCDN

+
+
+ + + + + + + + + + + + + + + + +
Packages 
PackageDescription
com.maxcdn 
tests.tests 
+
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/overview-tree.html b/doc/overview-tree.html new file mode 100644 index 0000000..d22e8c9 --- /dev/null +++ b/doc/overview-tree.html @@ -0,0 +1,163 @@ + + + + + +Class Hierarchy + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Hierarchy For All Packages

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/package-list b/doc/package-list new file mode 100644 index 0000000..a05f17c --- /dev/null +++ b/doc/package-list @@ -0,0 +1,2 @@ +com.maxcdn +tests.tests diff --git a/doc/script.js b/doc/script.js new file mode 100644 index 0000000..b346356 --- /dev/null +++ b/doc/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/doc/serialized-form.html b/doc/serialized-form.html new file mode 100644 index 0000000..565c43f --- /dev/null +++ b/doc/serialized-form.html @@ -0,0 +1,137 @@ + + + + + +Serialized Form + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Serialized Form

+
+
+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/stylesheet.css b/doc/stylesheet.css new file mode 100644 index 0000000..98055b2 --- /dev/null +++ b/doc/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/doc/tests/tests/ApiDemo.html b/doc/tests/tests/ApiDemo.html new file mode 100644 index 0000000..efbb9dd --- /dev/null +++ b/doc/tests/tests/ApiDemo.html @@ -0,0 +1,271 @@ + + + + + +ApiDemo + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + + +
+
tests.tests
+

Class ApiDemo

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/tests/tests/class-use/ApiDemo.html b/doc/tests/tests/class-use/ApiDemo.html new file mode 100644 index 0000000..9bc6ebd --- /dev/null +++ b/doc/tests/tests/class-use/ApiDemo.html @@ -0,0 +1,124 @@ + + + + + +Uses of Class tests.tests.ApiDemo + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Class
tests.tests.ApiDemo

+
+
No usage of tests.tests.ApiDemo
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/tests/tests/package-frame.html b/doc/tests/tests/package-frame.html new file mode 100644 index 0000000..427e347 --- /dev/null +++ b/doc/tests/tests/package-frame.html @@ -0,0 +1,20 @@ + + + + + +tests.tests + + + + + +

tests.tests

+
+

Classes

+ +
+ + diff --git a/doc/tests/tests/package-summary.html b/doc/tests/tests/package-summary.html new file mode 100644 index 0000000..c78c0c2 --- /dev/null +++ b/doc/tests/tests/package-summary.html @@ -0,0 +1,142 @@ + + + + + +tests.tests + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Package tests.tests

+
+
+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/tests/tests/package-tree.html b/doc/tests/tests/package-tree.html new file mode 100644 index 0000000..8eaa0e4 --- /dev/null +++ b/doc/tests/tests/package-tree.html @@ -0,0 +1,137 @@ + + + + + +tests.tests Class Hierarchy + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Hierarchy For Package tests.tests

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/doc/tests/tests/package-use.html b/doc/tests/tests/package-use.html new file mode 100644 index 0000000..eb2c2ef --- /dev/null +++ b/doc/tests/tests/package-use.html @@ -0,0 +1,124 @@ + + + + + +Uses of Package tests.tests + + + + + + + + +
+ + +
Skip navigation links
+ + + + +
+ + +
+

Uses of Package
tests.tests

+
+
No usage of tests.tests
+ +
+ + +
Skip navigation links
+ + + + +
+ + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..45fd73a --- /dev/null +++ b/pom.xml @@ -0,0 +1,20 @@ + + 4.0.0 + com.maxcdn + maxcdn + 0.0.1 + MaxCDN + MaxCDN Java API client. + + + org.json + json + 20171018 + + + org.scribe + scribe + 1.3.7 + + + diff --git a/src/com/maxcdn/MaxCDN.java b/src/com/maxcdn/MaxCDN.java index 2922748..316eb7a 100644 --- a/src/com/maxcdn/MaxCDN.java +++ b/src/com/maxcdn/MaxCDN.java @@ -1,6 +1,12 @@ package com.maxcdn; +/** + * MaxCDN - Java API client + * @author Cheikh Seck + * @version 0.0.1 + */ import java.security.SignatureException; +import org.json.JSONException; import org.scribe.builder.ServiceBuilder; import org.scribe.model.OAuthRequest; @@ -13,12 +19,31 @@ public class MaxCDN { + /** + * Instance's API alias. + */ public String alias; + /** + * Instance's API key. + */ public String key; + /** + * Instance's API secret. + */ public String secret; + /** + * Access token of instance. + */ private Token token_stored; + /** + * MaxCDN RWS URL + */ public String MaxCDNrws_url = "https://rws.maxcdn.com/"; + + /** + * Initialize client without API access token. + */ public MaxCDN(String alias, String consumer_key, String consumer_secret){ this.alias = alias; this.key = consumer_key; @@ -27,7 +52,10 @@ public MaxCDN(String alias, String consumer_key, String consumer_secret){ } - + /** + * Initialize client with API token. + * @param token String of a valid API token. + */ public MaxCDN(String alias, String consumer_key, String consumer_secret,Token token){ this.alias = alias; this.key = consumer_key; @@ -36,22 +64,44 @@ public MaxCDN(String alias, String consumer_key, String consumer_secret,Token to } - /* - * API Methods + /** + * Perform a request with verb GET to specified endpoint. + * @param endpoint API endpoint to perform GET request on. + * @return MaxCDNObject */ - public MaxCDNObject get(String endpoint){ + public MaxCDNObject get(String endpoint) throws JSONException,SignatureException, Exception { return this.request(endpoint, Verb.GET, null); } - public MaxCDNObject delete(String endpoint){ + /** + * Perform a request with verb DELETE to specified endpoint. + * @param endpoint String of API endpoint to use. + * @return MaxCDNObject + */ + public MaxCDNObject delete(String endpoint) throws JSONException,SignatureException, Exception { return this.request(endpoint, Verb.DELETE, null); } - public MaxCDNObject put(String endpoint, MaxCDNRequest request){ + /** + * Perform a request with verb PUT to specified endpoint. + * @param endpoint String of API endpoint to use. + * @param request Data to be submitted with request. + * @return MaxCDNObject + */ + public MaxCDNObject put(String endpoint, MaxCDNRequest request) throws JSONException,SignatureException, Exception{ return this.request(endpoint, Verb.PUT, request); } - public MaxCDNObject post(String endpoint, MaxCDNRequest request){ + /** + * Perform a request with verb POST to specified endpoint. + * @param endpoint String of API endpoint to use. + * @param request Data to be submitted with request. + * @return MaxCDNObject + */ + public MaxCDNObject post(String endpoint, MaxCDNRequest request) throws JSONException,SignatureException, Exception{ return this.request(endpoint, Verb.POST, request); } + /** + * Generate a request token. + */ public Token getRequestToken(){ OAuthService service = new ServiceBuilder() .provider(MaxCDNApi.class) @@ -60,7 +110,11 @@ public Token getRequestToken(){ .build(); return service.getRequestToken(); } - + /** + * Get authorization URL. + * @param requestToken. + * @return String of authorization URL. + */ public String getAuthUrl(Token requestToken){ // Obtain the Request Token OAuthService service = new ServiceBuilder() @@ -73,6 +127,12 @@ public String getAuthUrl(Token requestToken){ return service.getAuthorizationUrl(requestToken); } + /** + * Get access token from MaxCDN. + * @param requestToken Request token to submit with request. + * @param verify Temporary access token to get long lived access token. + * @return + */ public Token getAccessToken(Token requestToken, String verify){ OAuthService service = new ServiceBuilder() .provider(MaxCDNApi.class) @@ -82,29 +142,34 @@ public Token getAccessToken(Token requestToken, String verify){ return service.getAccessToken(requestToken, new Verifier(verify) ); } - public synchronized MaxCDNObject request(String end, Verb verb, MaxCDNRequest body){ - try { + /** + * Perform a request wih a custom verb. The current instance's access token will be used. + * @param end String of API endpoint to use. + * @param verb String of request verb to use. + * @param body Data to be submitted with request. + * @return MaxCDNObject + */ + public synchronized MaxCDNObject request(String end, Verb verb, MaxCDNRequest body) throws JSONException,SignatureException, Exception { if(token_stored == null) return new MaxCDNObject(this._request(end, verb, body)); else return new MaxCDNObject(this._request(end, verb, body,token_stored)); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } } - public synchronized MaxCDNObject request(String end, Verb verb, MaxCDNRequest body,Token token){ - try { + + /** + * Perform a request wih a custom verb and access token. + * @param end String of API endpoint to use. + * @param verb String of request verb to use. + * @param body Data to be submitted with request. + * @param token access token to use with request. + * @return MaxCDNObject + */ + public synchronized MaxCDNObject request(String end, Verb verb, MaxCDNRequest body,Token token) throws JSONException,SignatureException, Exception { return new MaxCDNObject(this._request(end, verb, body,token)); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } } - /* - * Manually setting the access token + /** + * Set access token + * @param token Token to set as the instance's token. */ public boolean setToken(Token token){ token_stored = token; @@ -121,7 +186,7 @@ public synchronized String _request(String end, Verb verb, MaxCDNRequest body,To .apiSecret(secret) .build(); - OAuthRequest request = new OAuthRequest(verb, this.MaxCDNrws_url + alias + end); + OAuthRequest request = new OAuthRequest(verb, String.format("%s%s%s", this.MaxCDNrws_url , alias, end)); request.addHeader("User-Agent", "Java MaxCDN API Client"); if(verb == Verb.PUT || verb == Verb.POST){ for(int i = 0;i < body.names().length(); i++){ diff --git a/src/com/maxcdn/MaxCDNApi.java b/src/com/maxcdn/MaxCDNApi.java index d98b78f..ce2ec20 100644 --- a/src/com/maxcdn/MaxCDNApi.java +++ b/src/com/maxcdn/MaxCDNApi.java @@ -17,13 +17,13 @@ public class MaxCDNApi extends DefaultApi10a { @Override public String getAccessTokenEndpoint() { - return "https://" + ACCESS_TOKEN_RESOURCE; + return String.format("https://%s", ACCESS_TOKEN_RESOURCE); } @Override public String getRequestTokenEndpoint() { - return "https://" + REQUEST_TOKEN_RESOURCE; + return String.format("https://%s", REQUEST_TOKEN_RESOURCE); } diff --git a/src/com/maxcdn/MaxCDNException.java b/src/com/maxcdn/MaxCDNException.java new file mode 100644 index 0000000..31f269c --- /dev/null +++ b/src/com/maxcdn/MaxCDNException.java @@ -0,0 +1,9 @@ +package com.maxcdn; + +@SuppressWarnings("serial") +public class MaxCDNException extends Exception { + + public MaxCDNException(String message){ + super(message); + } +} diff --git a/src/com/maxcdn/MaxCDNObject.java b/src/com/maxcdn/MaxCDNObject.java index b7f5c12..161fecf 100644 --- a/src/com/maxcdn/MaxCDNObject.java +++ b/src/com/maxcdn/MaxCDNObject.java @@ -3,23 +3,31 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import com.maxcdn.MaxCDNException; public class MaxCDNObject extends JSONObject { + /** + * Code of request. + */ public int code; + /** + * Specifies if request has error. + */ public boolean error = false; public MaxCDNObject() throws JSONException{ super(); - //this.put(key, data); - //code = this.getInt("code"); } - public MaxCDNObject(String json) throws JSONException{ + public MaxCDNObject(String json) throws JSONException,MaxCDNException { super(new JSONObject(json).has("data") ? ((JSONObject) new JSONObject(json).get("data")).toString() : json ); + error = this.has("error"); + if( error ){ + throw new MaxCDNException( this.getJson("error").getString("message") ); + } code = new JSONObject(json).getInt("code"); - if(this.has("error")) error = true; } - public String getErrorMessage(){ + public String getErrorMessage() throws JSONException { return error ? this.getJson("error").getString("message") : null; } public MaxCDNObject(String key,Object data) throws JSONException{ @@ -31,53 +39,27 @@ public MaxCDNObject(Object json) throws JSONException{ super(((JSONObject)json).toString() ); } - - public MaxCDNObject append(String key, Object value){ - try { - this.put(key, value); - } catch (JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + /** + * Set/Add key and object pair. use method remove(Object value) to remove a key. + * @return MaxCDNObject + */ + public MaxCDNObject append(String key, Object value) throws JSONException{ + this.put(key, value); + return this; } - public MaxCDNObject getJson(String key){ - try { + public MaxCDNObject getJson(String key) throws JSONException{ return new MaxCDNObject(this.get(key)); - } catch (JSONException e) { - - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } } - public Number getNumber(String key){ - try { + public Number getNumber(String key) throws JSONException { return (Number) this.get(key); - } catch (JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } } - public String getString(String key){ - try { + public String getString(String key) throws JSONException{ return (String) this.get(key); - } catch (JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } } - public JSONArray getArray(String key){ - try { + public JSONArray getArray(String key) throws JSONException{ return this.getJSONArray(key); - } catch (JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } } } diff --git a/src/com/maxcdn/MaxCDNRequest.java b/src/com/maxcdn/MaxCDNRequest.java index 72ce6c0..ebb6949 100644 --- a/src/com/maxcdn/MaxCDNRequest.java +++ b/src/com/maxcdn/MaxCDNRequest.java @@ -2,13 +2,14 @@ import org.json.JSONException; + public class MaxCDNRequest extends MaxCDNObject { public MaxCDNRequest() throws JSONException { super(); // TODO Auto-generated constructor stub } - public MaxCDNRequest(String json) throws JSONException { + public MaxCDNRequest(String json) throws JSONException, MaxCDNException { super(json); // TODO Auto-generated constructor stub } @@ -17,13 +18,8 @@ public MaxCDNRequest(String key,Object data) throws JSONException{ this.put(key, data); //code = this.getInt("code"); } - public MaxCDNRequest append(String key, Object value){ - try { - this.put(key, value); - } catch (JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + public MaxCDNRequest append(String key, Object value) throws JSONException { + this.put(key, value); return this; } diff --git a/tests/tests/ApiDemo.java b/tests/tests/ApiDemo.java index d69e571..058d7ff 100644 --- a/tests/tests/ApiDemo.java +++ b/tests/tests/ApiDemo.java @@ -1,4 +1,4 @@ -package tests; +package tests.tests; @@ -20,16 +20,16 @@ public static void main(String[] args) { //Console.log(api.getAuthUrl(api.getRequestToken())); - + try { MaxCDNObject data = api.get("/account.json"); if(!data.error) Console.log(data); else { - Console.log("Error " + data.getErrorMessage()); + Console.log("Error ".concat(data.getErrorMessage()) ); } - try { + MaxCDNObject post_example = api.post("/zones/push.json", new MaxCDNRequest("name", "NewZone91").append("password", "password")); if(post_example.error){ Console.log(post_example.getErrorMessage()); @@ -39,6 +39,8 @@ public static void main(String[] args) { } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); + } catch (Exception e){ + e.printStackTrace(); }