Skip to content

hadashiA/suzuri-actionscript-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

suzuri-actionscript-client

A wrapper around the v1 SUZURI API.

Dependencies

Usage

Authorization

import jp.suzuri.SuzuriClient;
import jp.suzuri.events.SuzuriAuthorizedEvent;
import jp.suzuri.events.SuzuriResponseEvent;

var webView:StageWebView = new StageWebView();
webView.viewPort = new Rectangle(0, 0, this.stage.width, this.stage.height);

var suzuriClient:SuzuriClient = new SuzuriClient(
	webView, 
	"YOUR CLIENT ID",
	"YOUR CLIENT SECRET",
	
    // YOUR REDIRECT URL
    // For Air, and not redirected
	"https://suzuri.jp/tosute"
);

// Authorized callback
suzuriClient.addEventListener(SuzuriAuthorizedEvent.TYPE, function(event:SuzuriAuthorizedEvent) {
	if (event.errorCode == null) {
		trace("--> aurhotized!! accessToken: " + suzuriClient.accessToken);
	} else {
		trace(event.errorMessage);
	}
	webView.stage = null;
});


// Authorization call
if (accessToken) {
  // No authentication is required if there is an access token. (or API KEY)
  suzuriClient.accessToken = accessToken;
} else {
  suzuriClient.authorize();
}

API Call Example

// All Request dispatch event for SuzuriResponeEvent
suzuriClient.addEventListener(SuzuriResponseEvent.TYPE, function(event:SuzuriResponseEvent) {
	var body:Object = event.body;
	
	if (event.success) {
		if (body.material) {
			trace("==> material id: " + body.material.id);
			trace("==> title: " + body.products[0].title);
			trace("==> description: " + body.products[0].description);
			trace("==> sampleImageUrl: " + body.products[0].sampleImageUrl);
			trace("==> sampleUrl:" + body.products[0].sampleUrl);
		} else if (body.user) {
			trace("==> name: " + body.user.name);
		}
		var material = event.body.material;
		trace(event.body);
	} else {
		// エラー
		trace(event.body);
	}
});


var attributes = {
	title: "チャメ林チョメ夫",
	description: "めちゃストイックやしめちゃ夜とかに修行してるしめちゃ自己啓発本とかも読む侍をプリントしました",
	products: [
		{ 
			itemId: 1,             // 1 = t-shirt
			published: true,       // 
			resizeMode: "contain"  // "contain" = Scale the image to the largest size such that both its width and its height can fit inside the t-shirt print area
		}
	]
};
suzuriClient.createMaterialFromBitmapData(bitmapdata, attributes);

Create Material Interface

  • createMaterialFromBitmapData(bitmapData:BitmapData, attributes:Object)
  • createMaterialFromBitmapData(png:ByteArray, attributes:Object)

Generic Requests

suzuri-actionscript-client has get, post, put, and delete functions which can make requests with the specified HTTP method to any endpoint.

suzuriClient.request(URLRequestMethod.PUT, 'materials/' + materialID, { price: 500 })

Reference

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages