For non required fields, you can either omit from the JSON string or set it to a default value
(e.g. String = "", Integer/Double = 0, Boolean = false, DateTime = 1900-01-01T00:00:00.000Z)
{"auth": {"api_username": "", "api_password": "", "api_key": "", "company_no": 0, "username": "", "password": "", "timezone_offset": 0, "auth_type": "", "system_name": "", "system_company_no": 0 }, "order": {"cascadeToVariations": false, "customer_address_no": 0, "customer_attribute_no": 0, "notify": false, "purchase_order": "", "relation_type": "", "timezone": "", "customer_no": 0, "external_order_no": "", "order_shipping_no": 0, "pricing_no": 0, "product_sku": "", "username": "", "address_type": "", "attribute_type": "", "cart_no": 0, "description": "", "order_sync": "", "settings": "", "address1": "", "attribute_value": "", "generatePassword": false, "product_no": 0, "sync_status": "", "created_on": "1/1/1900 12:00 AM", "inventory": 0, "last_sync": "1/1/1900 12:00 AM", "price_type": "", "profile_photo": "", "shipping_courier": "", "balance_due": 0, "cart_quantity": 0, "company_no": 0, "foursquare_handle": "", "product_short": "", "shipping_method": "", "cart_price": 0, "foursquare_id": "", "main_photo": "", "order_via": "", "quantity_discount": 0, "tracking_number": "", "customer_status": "", "price": 0, "product_attributes": "", "shipping_status": "", "skipEmailConfirmation": false, "order_no": 0, "price_description": "", "shipping_quantity": 0, "facebook_handle": "", "order_item_no": 0, "session_id": "", "start_date": "1/1/1900 12:00 AM", "address_notes": "", "end_date": "1/1/1900 12:00 AM", "order_date": "1/1/1900 12:00 AM", "twitter_handle": "", "address_verified": false, "google_handle": "", "cart_flag": "", "instagram_handle": "", "order_status": "", "latitude": "", "order_total": 0, "longitude": "", "sub_total": 0, "shipping_total": 0, "first_name": "", "tax_total": 0, "discount_total": 0, "last_name": "", "address": "", "tip_total": 0, "address2": "", "sessionID": "", "city": "", "ip_address": "", "state": "", "zip_code": "", "country": "", "phone_number": "", "mobile_number": "", "order_note": "", "email": "", "order_type": "", "flag_paid": 0, "password": "", "flag_verified": 0, "device_type": "", "flag_pulled": 0, "flag_shipped": 0, "passbook_enabled": "", "flag_completed": 0, "wallet_enabled": "", "flag_followup": 0, "opt_in_email": "", "flag_returned": 0, "opt_in_sms": "", "flag_modified": 0, "opt_in_updates": "", "flag_paid_date": "1/1/1900 12:00 AM", "flag_verified_date": "1/1/1900 12:00 AM", "user_no": 0, "company_name": "", "flag_pulled_date": "1/1/1900 12:00 AM", "birthdate": "1/1/1900 12:00 AM", "flag_shipped_date": "1/1/1900 12:00 AM", "flag_completed_date": "1/1/1900 12:00 AM", "modified_on": "1/1/1900 12:00 AM", "address3": "", "flag_followup_date": "1/1/1900 12:00 AM", "customer_reference": "", "flag_returned_date": "1/1/1900 12:00 AM", "facebook_id": "", "flag_modified_date": "1/1/1900 12:00 AM", "affiliate_no": 0, "twitter_id": "", "google_id": "", "instagram_id": "", "middle_name": "", "website": "", "customer_type": "" } }
{"auth": {"api_username": "", "api_password": "", "api_key": "", "company_no": 0, "username": "", "password": "" }, "order": {"cascadeToVariations": false, "customer_address_no": 0, "customer_attribute_no": 0, "notify": false, "purchase_order": "", "relation_type": "", "timezone": "", "customer_no": 0, "external_order_no": "", "order_shipping_no": 0, "pricing_no": 0, "product_sku": "", "username": "", "address_type": "", "attribute_type": "", "cart_no": 0, "description": "", "order_sync": "", "settings": "", "address1": "", "attribute_value": "", "generatePassword": false, "product_no": 0, "sync_status": "", "created_on": "1/1/1900 12:00 AM", "inventory": 0, "last_sync": "1/1/1900 12:00 AM", "price_type": "", "profile_photo": "", "shipping_courier": "", "balance_due": 0, "cart_quantity": 0, "company_no": 0, "foursquare_handle": "", "product_short": "", "shipping_method": "", "cart_price": 0, "foursquare_id": "", "main_photo": "", "order_via": "", "quantity_discount": 0, "tracking_number": "", "customer_status": "", "price": 0, "product_attributes": "", "shipping_status": "", "skipEmailConfirmation": false, "order_no": 0, "price_description": "", "shipping_quantity": 0, "facebook_handle": "", "order_item_no": 0, "session_id": "", "start_date": "1/1/1900 12:00 AM", "address_notes": "", "end_date": "1/1/1900 12:00 AM", "order_date": "1/1/1900 12:00 AM", "twitter_handle": "", "address_verified": false, "google_handle": "", "cart_flag": "", "instagram_handle": "", "order_status": "", "latitude": "", "order_total": 0, "longitude": "", "sub_total": 0, "shipping_total": 0, "first_name": "", "tax_total": 0, "discount_total": 0, "last_name": "", "address": "", "tip_total": 0, "address2": "", "sessionID": "", "city": "", "ip_address": "", "state": "", "zip_code": "", "country": "", "phone_number": "", "mobile_number": "", "order_note": "", "email": "", "order_type": "", "flag_paid": 0, "password": "", "flag_verified": 0, "device_type": "", "flag_pulled": 0, "flag_shipped": 0, "passbook_enabled": "", "flag_completed": 0, "wallet_enabled": "", "flag_followup": 0, "opt_in_email": "", "flag_returned": 0, "opt_in_sms": "", "flag_modified": 0, "opt_in_updates": "", "flag_paid_date": "1/1/1900 12:00 AM", "flag_verified_date": "1/1/1900 12:00 AM", "user_no": 0, "company_name": "", "flag_pulled_date": "1/1/1900 12:00 AM", "birthdate": "1/1/1900 12:00 AM", "flag_shipped_date": "1/1/1900 12:00 AM", "flag_completed_date": "1/1/1900 12:00 AM", "modified_on": "1/1/1900 12:00 AM", "address3": "", "flag_followup_date": "1/1/1900 12:00 AM", "customer_reference": "", "flag_returned_date": "1/1/1900 12:00 AM", "facebook_id": "", "flag_modified_date": "1/1/1900 12:00 AM", "affiliate_no": 0, "twitter_id": "", "google_id": "", "instagram_id": "", "middle_name": "", "website": "", "customer_type": "" } }
This sample code is to generate a function leveraging existing core functions you've already built.
func getAPIKit() -> (url: String, dict: Dictionary<String, AnyObject>) {
var cascadeToVariations = false
var customer_address_no = 0
var customer_attribute_no = 0
var notify = false
var purchase_order = ""
var relation_type = ""
var timezone = ""
var customer_no = 0
var external_order_no = ""
var order_shipping_no = 0
var pricing_no = 0
var product_sku = ""
var username = ""
var address_type = ""
var attribute_type = ""
var cart_no = 0
var description = ""
var order_sync = ""
var settings = ""
var address1 = ""
var attribute_value = ""
var generatePassword = false
var product_no = 0
var sync_status = ""
var created_on = "1/1/1900 12:00 AM"
var inventory = 0
var last_sync = "1/1/1900 12:00 AM"
var price_type = ""
var profile_photo = ""
var shipping_courier = ""
var balance_due = 0
var cart_quantity = 0
var company_no = 0
var foursquare_handle = ""
var product_short = ""
var shipping_method = ""
var cart_price = 0
var foursquare_id = ""
var main_photo = ""
var order_via = ""
var quantity_discount = 0
var tracking_number = ""
var customer_status = ""
var price = 0
var product_attributes = ""
var shipping_status = ""
var skipEmailConfirmation = false
var order_no = 0
var price_description = ""
var shipping_quantity = 0
var facebook_handle = ""
var order_item_no = 0
var session_id = ""
var start_date = "1/1/1900 12:00 AM"
var address_notes = ""
var end_date = "1/1/1900 12:00 AM"
var order_date = "1/1/1900 12:00 AM"
var twitter_handle = ""
var address_verified = false
var google_handle = ""
var cart_flag = ""
var instagram_handle = ""
var order_status = ""
var latitude = ""
var order_total = 0
var longitude = ""
var sub_total = 0
var shipping_total = 0
var first_name = ""
var tax_total = 0
var discount_total = 0
var last_name = ""
var address = ""
var tip_total = 0
var address2 = ""
var sessionID = ""
var city = ""
var ip_address = ""
var state = ""
var zip_code = ""
var country = ""
var phone_number = ""
var mobile_number = ""
var order_note = ""
var email = ""
var order_type = ""
var flag_paid = 0
var password = ""
var flag_verified = 0
var device_type = ""
var flag_pulled = 0
var flag_shipped = 0
var passbook_enabled = ""
var flag_completed = 0
var wallet_enabled = ""
var flag_followup = 0
var opt_in_email = ""
var flag_returned = 0
var opt_in_sms = ""
var flag_modified = 0
var opt_in_updates = ""
var flag_paid_date = "1/1/1900 12:00 AM"
var flag_verified_date = "1/1/1900 12:00 AM"
var user_no = 0
var company_name = ""
var flag_pulled_date = "1/1/1900 12:00 AM"
var birthdate = "1/1/1900 12:00 AM"
var flag_shipped_date = "1/1/1900 12:00 AM"
var flag_completed_date = "1/1/1900 12:00 AM"
var modified_on = "1/1/1900 12:00 AM"
var address3 = ""
var flag_followup_date = "1/1/1900 12:00 AM"
var customer_reference = ""
var flag_returned_date = "1/1/1900 12:00 AM"
var facebook_id = ""
var flag_modified_date = "1/1/1900 12:00 AM"
var affiliate_no = 0
var twitter_id = ""
var google_id = ""
var instagram_id = ""
var middle_name = ""
var website = ""
var customer_type = ""
let url = "https://api.peoplevine.com/commerce.asmx/generateQuote"
let key = "order"
let orderDict: Dictionary<String, AnyObject> = ["cascadeToVariations": cascadeToVariations, "customer_address_no": customer_address_no, "customer_attribute_no": customer_attribute_no, "notify": notify, "purchase_order": purchase_order, "relation_type": relation_type, "timezone": timezone, "customer_no": customer_no, "external_order_no": external_order_no, "order_shipping_no": order_shipping_no, "pricing_no": pricing_no, "product_sku": product_sku, "username": username, "address_type": address_type, "attribute_type": attribute_type, "cart_no": cart_no, "description": description, "order_sync": order_sync, "settings": settings, "address1": address1, "attribute_value": attribute_value, "generatePassword": generatePassword, "product_no": product_no, "sync_status": sync_status, "created_on": created_on, "inventory": inventory, "last_sync": last_sync, "price_type": price_type, "profile_photo": profile_photo, "shipping_courier": shipping_courier, "balance_due": balance_due, "cart_quantity": cart_quantity, "company_no": company_no, "foursquare_handle": foursquare_handle, "product_short": product_short, "shipping_method": shipping_method, "cart_price": cart_price, "foursquare_id": foursquare_id, "main_photo": main_photo, "order_via": order_via, "quantity_discount": quantity_discount, "tracking_number": tracking_number, "customer_status": customer_status, "price": price, "product_attributes": product_attributes, "shipping_status": shipping_status, "skipEmailConfirmation": skipEmailConfirmation, "order_no": order_no, "price_description": price_description, "shipping_quantity": shipping_quantity, "facebook_handle": facebook_handle, "order_item_no": order_item_no, "session_id": session_id, "start_date": start_date, "address_notes": address_notes, "end_date": end_date, "order_date": order_date, "twitter_handle": twitter_handle, "address_verified": address_verified, "google_handle": google_handle, "cart_flag": cart_flag, "instagram_handle": instagram_handle, "order_status": order_status, "latitude": latitude, "order_total": order_total, "longitude": longitude, "sub_total": sub_total, "shipping_total": shipping_total, "first_name": first_name, "tax_total": tax_total, "discount_total": discount_total, "last_name": last_name, "address": address, "tip_total": tip_total, "address2": address2, "sessionID": sessionID, "city": city, "ip_address": ip_address, "state": state, "zip_code": zip_code, "country": country, "phone_number": phone_number, "mobile_number": mobile_number, "order_note": order_note, "email": email, "order_type": order_type, "flag_paid": flag_paid, "password": password, "flag_verified": flag_verified, "device_type": device_type, "flag_pulled": flag_pulled, "flag_shipped": flag_shipped, "passbook_enabled": passbook_enabled, "flag_completed": flag_completed, "wallet_enabled": wallet_enabled, "flag_followup": flag_followup, "opt_in_email": opt_in_email, "flag_returned": flag_returned, "opt_in_sms": opt_in_sms, "flag_modified": flag_modified, "opt_in_updates": opt_in_updates, "flag_paid_date": flag_paid_date, "flag_verified_date": flag_verified_date, "user_no": user_no, "company_name": company_name, "flag_pulled_date": flag_pulled_date, "birthdate": birthdate, "flag_shipped_date": flag_shipped_date, "flag_completed_date": flag_completed_date, "modified_on": modified_on, "address3": address3, "flag_followup_date": flag_followup_date, "customer_reference": customer_reference, "flag_returned_date": flag_returned_date, "facebook_id": facebook_id, "flag_modified_date": flag_modified_date, "affiliate_no": affiliate_no, "twitter_id": twitter_id, "google_id": google_id, "instagram_id": instagram_id, "middle_name": middle_name, "website": website, "customer_type": customer_type ]
let finalDict = User.getAuthDict(dictToAdd: orderDict, dictKey: key)
return (url, finalDict)
}
To get started we reccomend that you download the Alamofire project to simplify integration: https://github.com/Alamofire/Alamofire, in addition to SwiftyJSON: https://github.com/SwiftyJSON/SwiftyJSON
import Foundation
struct AUTH {
static var api_username = <string>
static var api_password = <string>
static var api_key = <string>
static var company_no = <double>
static var username = <string>
static var password = <string>
static var timezone_offset = <double>
static var auth_type = <string>
static var system_name = <string>
static var system_company_no = <double>}
struct ORDER {
static var cascadeToVariations = <boolean>
static var customer_address_no = <double>
static var customer_attribute_no = <double>
static var notify = <boolean>
static var purchase_order = <string>
static var relation_type = <string>
static var timezone = <string>
static var customer_no = <double>
static var external_order_no = <string>
static var order_shipping_no = <double>
static var pricing_no = <double>
static var product_sku = <string>
static var username = <string>
static var address_type = <string>
static var attribute_type = <string>
static var cart_no = <double>
static var description = <string>
static var order_sync = <string>
static var settings = <string>
static var address1 = <string>
static var attribute_value = <string>
static var generatePassword = <boolean>
static var product_no = <double>
static var sync_status = <string>
static var created_on = <dateTime>
static var inventory = <double>
static var last_sync = <dateTime>
static var price_type = <string>
static var profile_photo = <string>
static var shipping_courier = <string>
static var balance_due = <double>
static var cart_quantity = <double>
static var company_no = <double>
static var foursquare_handle = <string>
static var product_short = <string>
static var shipping_method = <string>
static var cart_price = <double>
static var foursquare_id = <string>
static var main_photo = <string>
static var order_via = <string>
static var quantity_discount = <double>
static var tracking_number = <string>
static var customer_status = <string>
static var price = <double>
static var product_attributes = <string>
static var shipping_status = <string>
static var skipEmailConfirmation = <boolean>
static var order_no = <double>
static var price_description = <string>
static var shipping_quantity = <double>
static var facebook_handle = <string>
static var order_item_no = <double>
static var session_id = <string>
static var start_date = <dateTime>
static var address_notes = <string>
static var end_date = <dateTime>
static var order_date = <dateTime>
static var twitter_handle = <string>
static var address_verified = <boolean>
static var google_handle = <string>
static var cart_flag = <string>
static var instagram_handle = <string>
static var order_status = <string>
static var latitude = <string>
static var order_total = <double>
static var longitude = <string>
static var sub_total = <double>
static var shipping_total = <double>
static var first_name = <string>
static var tax_total = <double>
static var discount_total = <double>
static var last_name = <string>
static var address = <string>
static var tip_total = <double>
static var address2 = <string>
static var sessionID = <string>
static var city = <string>
static var ip_address = <string>
static var state = <string>
static var zip_code = <string>
static var country = <string>
static var phone_number = <string>
static var mobile_number = <string>
static var order_note = <string>
static var email = <string>
static var order_type = <string>
static var flag_paid = <double>
static var password = <string>
static var flag_verified = <double>
static var device_type = <string>
static var flag_pulled = <double>
static var flag_shipped = <double>
static var passbook_enabled = <string>
static var flag_completed = <double>
static var wallet_enabled = <string>
static var flag_followup = <double>
static var opt_in_email = <string>
static var flag_returned = <double>
static var opt_in_sms = <string>
static var flag_modified = <double>
static var opt_in_updates = <string>
static var flag_paid_date = <dateTime>
static var flag_verified_date = <dateTime>
static var user_no = <double>
static var company_name = <string>
static var flag_pulled_date = <dateTime>
static var birthdate = <dateTime>
static var flag_shipped_date = <dateTime>
static var flag_completed_date = <dateTime>
static var modified_on = <dateTime>
static var address3 = <string>
static var flag_followup_date = <dateTime>
static var customer_reference = <string>
static var flag_returned_date = <dateTime>
static var facebook_id = <string>
static var flag_modified_date = <dateTime>
static var affiliate_no = <double>
static var twitter_id = <string>
static var google_id = <string>
static var instagram_id = <string>
static var middle_name = <string>
static var website = <string>
static var customer_type = <string>}
func generateQuoteRequest() {
var generateQuoteObjects = [AnyObject]()
let postsEndpoint: String = "https://api.peoplevine.com/commerce.asmx/generateQuote"
let authAndFieldsDict = ["auth": ["api_username": AUTH.api_username, "api_password": AUTH.api_password, "api_key": AUTH.api_key, "company_no": AUTH.company_no, "username": AUTH.username, "password": AUTH.password, "timezone_offset": AUTH.timezone_offset, "auth_type": AUTH.auth_type, "system_name": AUTH.system_name, "system_company_no": AUTH.system_company_no ], "order": ["cascadeToVariations": ORDER.cascadeToVariations, "customer_address_no": ORDER.customer_address_no, "customer_attribute_no": ORDER.customer_attribute_no, "notify": ORDER.notify, "purchase_order": ORDER.purchase_order, "relation_type": ORDER.relation_type, "timezone": ORDER.timezone, "customer_no": ORDER.customer_no, "external_order_no": ORDER.external_order_no, "order_shipping_no": ORDER.order_shipping_no, "pricing_no": ORDER.pricing_no, "product_sku": ORDER.product_sku, "username": ORDER.username, "address_type": ORDER.address_type, "attribute_type": ORDER.attribute_type, "cart_no": ORDER.cart_no, "description": ORDER.description, "order_sync": ORDER.order_sync, "settings": ORDER.settings, "address1": ORDER.address1, "attribute_value": ORDER.attribute_value, "generatePassword": ORDER.generatePassword, "product_no": ORDER.product_no, "sync_status": ORDER.sync_status, "created_on": ORDER.created_on, "inventory": ORDER.inventory, "last_sync": ORDER.last_sync, "price_type": ORDER.price_type, "profile_photo": ORDER.profile_photo, "shipping_courier": ORDER.shipping_courier, "balance_due": ORDER.balance_due, "cart_quantity": ORDER.cart_quantity, "company_no": ORDER.company_no, "foursquare_handle": ORDER.foursquare_handle, "product_short": ORDER.product_short, "shipping_method": ORDER.shipping_method, "cart_price": ORDER.cart_price, "foursquare_id": ORDER.foursquare_id, "main_photo": ORDER.main_photo, "order_via": ORDER.order_via, "quantity_discount": ORDER.quantity_discount, "tracking_number": ORDER.tracking_number, "customer_status": ORDER.customer_status, "price": ORDER.price, "product_attributes": ORDER.product_attributes, "shipping_status": ORDER.shipping_status, "skipEmailConfirmation": ORDER.skipEmailConfirmation, "order_no": ORDER.order_no, "price_description": ORDER.price_description, "shipping_quantity": ORDER.shipping_quantity, "facebook_handle": ORDER.facebook_handle, "order_item_no": ORDER.order_item_no, "session_id": ORDER.session_id, "start_date": ORDER.start_date, "address_notes": ORDER.address_notes, "end_date": ORDER.end_date, "order_date": ORDER.order_date, "twitter_handle": ORDER.twitter_handle, "address_verified": ORDER.address_verified, "google_handle": ORDER.google_handle, "cart_flag": ORDER.cart_flag, "instagram_handle": ORDER.instagram_handle, "order_status": ORDER.order_status, "latitude": ORDER.latitude, "order_total": ORDER.order_total, "longitude": ORDER.longitude, "sub_total": ORDER.sub_total, "shipping_total": ORDER.shipping_total, "first_name": ORDER.first_name, "tax_total": ORDER.tax_total, "discount_total": ORDER.discount_total, "last_name": ORDER.last_name, "address": ORDER.address, "tip_total": ORDER.tip_total, "address2": ORDER.address2, "sessionID": ORDER.sessionID, "city": ORDER.city, "ip_address": ORDER.ip_address, "state": ORDER.state, "zip_code": ORDER.zip_code, "country": ORDER.country, "phone_number": ORDER.phone_number, "mobile_number": ORDER.mobile_number, "order_note": ORDER.order_note, "email": ORDER.email, "order_type": ORDER.order_type, "flag_paid": ORDER.flag_paid, "password": ORDER.password, "flag_verified": ORDER.flag_verified, "device_type": ORDER.device_type, "flag_pulled": ORDER.flag_pulled, "flag_shipped": ORDER.flag_shipped, "passbook_enabled": ORDER.passbook_enabled, "flag_completed": ORDER.flag_completed, "wallet_enabled": ORDER.wallet_enabled, "flag_followup": ORDER.flag_followup, "opt_in_email": ORDER.opt_in_email, "flag_returned": ORDER.flag_returned, "opt_in_sms": ORDER.opt_in_sms, "flag_modified": ORDER.flag_modified, "opt_in_updates": ORDER.opt_in_updates, "flag_paid_date": ORDER.flag_paid_date, "flag_verified_date": ORDER.flag_verified_date, "user_no": ORDER.user_no, "company_name": ORDER.company_name, "flag_pulled_date": ORDER.flag_pulled_date, "birthdate": ORDER.birthdate, "flag_shipped_date": ORDER.flag_shipped_date, "flag_completed_date": ORDER.flag_completed_date, "modified_on": ORDER.modified_on, "address3": ORDER.address3, "flag_followup_date": ORDER.flag_followup_date, "customer_reference": ORDER.customer_reference, "flag_returned_date": ORDER.flag_returned_date, "facebook_id": ORDER.facebook_id, "flag_modified_date": ORDER.flag_modified_date, "affiliate_no": ORDER.affiliate_no, "twitter_id": ORDER.twitter_id, "google_id": ORDER.google_id, "instagram_id": ORDER.instagram_id, "middle_name": ORDER.middle_name, "website": ORDER.website, "customer_type": ORDER.customer_type ] ]
Alamofire.request(.POST, postsEndpoint, parameters: authAndFieldsDict, encoding: .JSON).responseJSON { (request, response, data, error) in
if let anError = error {
println("error calling POST on /posts")
println(error)
} else if let jsonData: AnyObject = data {
if let dataString = (jsonData.valueForKey("d") as! String).dataUsingEncoding(NSUTF8StringEncoding) {
let json = JSON(data: dataString) //use this object to parse data
//SAMPLE PARSING
let varData = json["returnObject"][0]["object"].stringValue
// ----------
// BELOW REPRESENTS AN EXAMPLE USING PURE SWIFT JSONSERIALIZATION INSTEAD OF SWIFTYJSON --------//
// if let generateQuoteDict = NSJSONSerialization.JSONObjectWithData(encoString, options: .MutableContainers, error: nil) as? NSDictionary {
// if let returnObjectArray = generateQuoteDict["returnObject"] as? NSArray {
//
// for generateQuoteObject in returnObjectArray {
// generateQuoteObjects.append(generateQuoteObject)
// if let item = generateQuoteObject["object_name"] as? NSDictionary {
// let varItem = item["field_name"] as! String
// }
// }
//
// println("\n\(generateQuoteObjects.count) Total")
// }
// }
}
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>API Call - generateQuote</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var dataValue = {
"auth": {
"api_username": "",
"api_password": "",
"api_key": "",
"company_no": 0,
"username": "",
"password": "",
"timezone_offset": 0,
"auth_type": "",
"system_name": "",
"system_company_no": 0,
},
"order": {
"cascadeToVariations": false,
"customer_address_no": 0,
"customer_attribute_no": 0,
"notify": false,
"purchase_order": "",
"relation_type": "",
"timezone": "",
"customer_no": 0,
"external_order_no": "",
"order_shipping_no": 0,
"pricing_no": 0,
"product_sku": "",
"username": "",
"address_type": "",
"attribute_type": "",
"cart_no": 0,
"description": "",
"order_sync": "",
"settings": "",
"address1": "",
"attribute_value": "",
"generatePassword": false,
"product_no": 0,
"sync_status": "",
"created_on": "1/1/1900 12:00 AM",
"inventory": 0,
"last_sync": "1/1/1900 12:00 AM",
"price_type": "",
"profile_photo": "",
"shipping_courier": "",
"balance_due": 0,
"cart_quantity": 0,
"company_no": 0,
"foursquare_handle": "",
"product_short": "",
"shipping_method": "",
"cart_price": 0,
"foursquare_id": "",
"main_photo": "",
"order_via": "",
"quantity_discount": 0,
"tracking_number": "",
"customer_status": "",
"price": 0,
"product_attributes": "",
"shipping_status": "",
"skipEmailConfirmation": false,
"order_no": 0,
"price_description": "",
"shipping_quantity": 0,
"facebook_handle": "",
"order_item_no": 0,
"session_id": "",
"start_date": "1/1/1900 12:00 AM",
"address_notes": "",
"end_date": "1/1/1900 12:00 AM",
"order_date": "1/1/1900 12:00 AM",
"twitter_handle": "",
"address_verified": false,
"google_handle": "",
"cart_flag": "",
"instagram_handle": "",
"order_status": "",
"latitude": "",
"order_total": 0,
"longitude": "",
"sub_total": 0,
"shipping_total": 0,
"first_name": "",
"tax_total": 0,
"discount_total": 0,
"last_name": "",
"address": "",
"tip_total": 0,
"address2": "",
"sessionID": "",
"city": "",
"ip_address": "",
"state": "",
"zip_code": "",
"country": "",
"phone_number": "",
"mobile_number": "",
"order_note": "",
"email": "",
"order_type": "",
"flag_paid": 0,
"password": "",
"flag_verified": 0,
"device_type": "",
"flag_pulled": 0,
"flag_shipped": 0,
"passbook_enabled": "",
"flag_completed": 0,
"wallet_enabled": "",
"flag_followup": 0,
"opt_in_email": "",
"flag_returned": 0,
"opt_in_sms": "",
"flag_modified": 0,
"opt_in_updates": "",
"flag_paid_date": "1/1/1900 12:00 AM",
"flag_verified_date": "1/1/1900 12:00 AM",
"user_no": 0,
"company_name": "",
"flag_pulled_date": "1/1/1900 12:00 AM",
"birthdate": "1/1/1900 12:00 AM",
"flag_shipped_date": "1/1/1900 12:00 AM",
"flag_completed_date": "1/1/1900 12:00 AM",
"modified_on": "1/1/1900 12:00 AM",
"address3": "",
"flag_followup_date": "1/1/1900 12:00 AM",
"customer_reference": "",
"flag_returned_date": "1/1/1900 12:00 AM",
"facebook_id": "",
"flag_modified_date": "1/1/1900 12:00 AM",
"affiliate_no": 0,
"twitter_id": "",
"google_id": "",
"instagram_id": "",
"middle_name": "",
"website": "",
"customer_type": "",
},
};
$.ajax({
url: 'https://api.peoplevine.com/commerce.asmx/generateQuote',
type: 'POST',
data: JSON.stringify(dataValue),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("ERROR");
},
success: function (result) {
var obj = JSON.parse(result.d).returnObject;
$.each(obj, function(i) {
$("#divID").html(obj[i].field_name); //do something with the data
})
}
})
});
</script>
</body>
</html>
System.Net.HttpWebRequest req = System.Net.HttpWebRequest.Create("https://api.peoplevine.com/commerce.asmx/generateQuote");
req.Method = "POST";
req.ContentType = "application/json; charset=utf-8";
string dataValue = "{auth: {api_username: <string>, api_password: <string>, api_key: <string>, company_no: <double>, username: <string>, password: <string>, timezone_offset: <double>, auth_type: <string>, system_name: <string>, system_company_no: <double> },order: {cascadeToVariations: <boolean>, customer_address_no: <double>, customer_attribute_no: <double>, notify: <boolean>, purchase_order: <string>, relation_type: <string>, timezone: <string>, customer_no: <double>, external_order_no: <string>, order_shipping_no: <double>, pricing_no: <double>, product_sku: <string>, username: <string>, address_type: <string>, attribute_type: <string>, cart_no: <double>, description: <string>, order_sync: <string>, settings: <string>, address1: <string>, attribute_value: <string>, generatePassword: <boolean>, product_no: <double>, sync_status: <string>, created_on: <dateTime>, inventory: <double>, last_sync: <dateTime>, price_type: <string>, profile_photo: <string>, shipping_courier: <string>, balance_due: <double>, cart_quantity: <double>, company_no: <double>, foursquare_handle: <string>, product_short: <string>, shipping_method: <string>, cart_price: <double>, foursquare_id: <string>, main_photo: <string>, order_via: <string>, quantity_discount: <double>, tracking_number: <string>, customer_status: <string>, price: <double>, product_attributes: <string>, shipping_status: <string>, skipEmailConfirmation: <boolean>, order_no: <double>, price_description: <string>, shipping_quantity: <double>, facebook_handle: <string>, order_item_no: <double>, session_id: <string>, start_date: <dateTime>, address_notes: <string>, end_date: <dateTime>, order_date: <dateTime>, twitter_handle: <string>, address_verified: <boolean>, google_handle: <string>, cart_flag: <string>, instagram_handle: <string>, order_status: <string>, latitude: <string>, order_total: <double>, longitude: <string>, sub_total: <double>, shipping_total: <double>, first_name: <string>, tax_total: <double>, discount_total: <double>, last_name: <string>, address: <string>, tip_total: <double>, address2: <string>, sessionID: <string>, city: <string>, ip_address: <string>, state: <string>, zip_code: <string>, country: <string>, phone_number: <string>, mobile_number: <string>, order_note: <string>, email: <string>, order_type: <string>, flag_paid: <double>, password: <string>, flag_verified: <double>, device_type: <string>, flag_pulled: <double>, flag_shipped: <double>, passbook_enabled: <string>, flag_completed: <double>, wallet_enabled: <string>, flag_followup: <double>, opt_in_email: <string>, flag_returned: <double>, opt_in_sms: <string>, flag_modified: <double>, opt_in_updates: <string>, flag_paid_date: <dateTime>, flag_verified_date: <dateTime>, user_no: <double>, company_name: <string>, flag_pulled_date: <dateTime>, birthdate: <dateTime>, flag_shipped_date: <dateTime>, flag_completed_date: <dateTime>, modified_on: <dateTime>, address3: <string>, flag_followup_date: <dateTime>, customer_reference: <string>, flag_returned_date: <dateTime>, facebook_id: <string>, flag_modified_date: <dateTime>, affiliate_no: <double>, twitter_id: <string>, google_id: <string>, instagram_id: <string>, middle_name: <string>, website: <string>, customer_type: <string> }}";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] bytes = encoding.GetBytes(dataValue);
req.ContentLength = bytes.Length;
System.IO.Stream strm = req.GetRequestStream();
strm.Write(bytes, 0, bytes.Length);
strm.Close();
System.Net.HttpWebResponse rsp = req.GetResponse();
System.IO.Stream data = rsp.GetResponseStream();
System.IO.StreamReader rdr = new System.IO.StreamReader(data);
string response = rdr.ReadToEnd();
Dim req As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://api.peoplevine.com/commerce.asmx/generateQuote")
req.Method = "POST"
req.ContentType = "application/json; charset=utf-8"
Dim dataValue As String = "{auth: {api_username: <string>, api_password: <string>, api_key: <string>, company_no: <double>, username: <string>, password: <string>, timezone_offset: <double>, auth_type: <string>, system_name: <string>, system_company_no: <double> },order: {cascadeToVariations: <boolean>, customer_address_no: <double>, customer_attribute_no: <double>, notify: <boolean>, purchase_order: <string>, relation_type: <string>, timezone: <string>, customer_no: <double>, external_order_no: <string>, order_shipping_no: <double>, pricing_no: <double>, product_sku: <string>, username: <string>, address_type: <string>, attribute_type: <string>, cart_no: <double>, description: <string>, order_sync: <string>, settings: <string>, address1: <string>, attribute_value: <string>, generatePassword: <boolean>, product_no: <double>, sync_status: <string>, created_on: <dateTime>, inventory: <double>, last_sync: <dateTime>, price_type: <string>, profile_photo: <string>, shipping_courier: <string>, balance_due: <double>, cart_quantity: <double>, company_no: <double>, foursquare_handle: <string>, product_short: <string>, shipping_method: <string>, cart_price: <double>, foursquare_id: <string>, main_photo: <string>, order_via: <string>, quantity_discount: <double>, tracking_number: <string>, customer_status: <string>, price: <double>, product_attributes: <string>, shipping_status: <string>, skipEmailConfirmation: <boolean>, order_no: <double>, price_description: <string>, shipping_quantity: <double>, facebook_handle: <string>, order_item_no: <double>, session_id: <string>, start_date: <dateTime>, address_notes: <string>, end_date: <dateTime>, order_date: <dateTime>, twitter_handle: <string>, address_verified: <boolean>, google_handle: <string>, cart_flag: <string>, instagram_handle: <string>, order_status: <string>, latitude: <string>, order_total: <double>, longitude: <string>, sub_total: <double>, shipping_total: <double>, first_name: <string>, tax_total: <double>, discount_total: <double>, last_name: <string>, address: <string>, tip_total: <double>, address2: <string>, sessionID: <string>, city: <string>, ip_address: <string>, state: <string>, zip_code: <string>, country: <string>, phone_number: <string>, mobile_number: <string>, order_note: <string>, email: <string>, order_type: <string>, flag_paid: <double>, password: <string>, flag_verified: <double>, device_type: <string>, flag_pulled: <double>, flag_shipped: <double>, passbook_enabled: <string>, flag_completed: <double>, wallet_enabled: <string>, flag_followup: <double>, opt_in_email: <string>, flag_returned: <double>, opt_in_sms: <string>, flag_modified: <double>, opt_in_updates: <string>, flag_paid_date: <dateTime>, flag_verified_date: <dateTime>, user_no: <double>, company_name: <string>, flag_pulled_date: <dateTime>, birthdate: <dateTime>, flag_shipped_date: <dateTime>, flag_completed_date: <dateTime>, modified_on: <dateTime>, address3: <string>, flag_followup_date: <dateTime>, customer_reference: <string>, flag_returned_date: <dateTime>, facebook_id: <string>, flag_modified_date: <dateTime>, affiliate_no: <double>, twitter_id: <string>, google_id: <string>, instagram_id: <string>, middle_name: <string>, website: <string>, customer_type: <string> }}"
Dim encoding As New ASCIIEncoding()
Dim bytes As Byte() = encoding.GetBytes(dataValue)
req.ContentLength = bytes.Length
Dim strm As System.IO.Stream = req.GetRequestStream()
strm.Write(bytes, 0, bytes.Length)
strm.Close()
Dim rsp As System.Net.HttpWebResponse = req.GetResponse()
Dim data As System.IO.Stream = rsp.GetResponseStream()
Dim rdr As New System.IO.StreamReader(data)
Dim response As String = rdr.ReadToEnd()
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample {
public static void main(String[] args) {
HttpClient httpclient = HttpClients.createDefault();
try
{
URIBuilder builder = new URIBuilder("https://peoplevine.azure-api.net/customer/customer/registerCustomer");
// Specify your subscription key
builder.setParameter("subscription-key", "");
URI uri = builder.build();
HttpPost request = new HttpPost(uri);
StringEntity reqEntity = new StringEntity("", ContentType.create("application/json"));
request.setEntity(reqEntity);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null) {
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<?php
// This sample uses the HTTP_Request2 package. (for more information: http://pear.php.net/package/HTTP_Request2)
require_once 'HTTP/Request2.php';
$headers = array(
'Content-Type' => 'application/json',
);
$query_params = array(
// Specify your subscription key
'subscription-key' => '',
);
$request = new Http_Request2('https://peoplevine.azure-api.net/customer/customer/registerCustomer');
$request->setMethod(HTTP_Request2::METHOD_POST);
// Basic Authorization Sample
// $request-setAuth('{username}', '{password}');
$request->setHeader($headers);
$url = $request->getUrl();
$url->setQueryVariables($query_params);
$request->setBody("");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
#import <Foundation/Foundation.h>
NSDictionary *authDic = [NSDictionary dictionaryWithObjectsAndKeys:
<string>, @"api_username",
<string>, @"api_password",
<string>, @"api_key",
<double>, @"company_no",
<string>, @"username",
<string>, @"password",
<double>, @"timezone_offset",
<string>, @"auth_type",
<string>, @"system_name",
<double>, @"system_company_no", nil];
NSDictionary *orderDic = [NSDictionary dictionaryWithObjectsAndKeys:
<boolean>, @"cascadeToVariations",
<double>, @"customer_address_no",
<double>, @"customer_attribute_no",
<boolean>, @"notify",
<string>, @"purchase_order",
<string>, @"relation_type",
<string>, @"timezone",
<double>, @"customer_no",
<string>, @"external_order_no",
<double>, @"order_shipping_no",
<double>, @"pricing_no",
<string>, @"product_sku",
<string>, @"username",
<string>, @"address_type",
<string>, @"attribute_type",
<double>, @"cart_no",
<string>, @"description",
<string>, @"order_sync",
<string>, @"settings",
<string>, @"address1",
<string>, @"attribute_value",
<boolean>, @"generatePassword",
<double>, @"product_no",
<string>, @"sync_status",
<dateTime>, @"created_on",
<double>, @"inventory",
<dateTime>, @"last_sync",
<string>, @"price_type",
<string>, @"profile_photo",
<string>, @"shipping_courier",
<double>, @"balance_due",
<double>, @"cart_quantity",
<double>, @"company_no",
<string>, @"foursquare_handle",
<string>, @"product_short",
<string>, @"shipping_method",
<double>, @"cart_price",
<string>, @"foursquare_id",
<string>, @"main_photo",
<string>, @"order_via",
<double>, @"quantity_discount",
<string>, @"tracking_number",
<string>, @"customer_status",
<double>, @"price",
<string>, @"product_attributes",
<string>, @"shipping_status",
<boolean>, @"skipEmailConfirmation",
<double>, @"order_no",
<string>, @"price_description",
<double>, @"shipping_quantity",
<string>, @"facebook_handle",
<double>, @"order_item_no",
<string>, @"session_id",
<dateTime>, @"start_date",
<string>, @"address_notes",
<dateTime>, @"end_date",
<dateTime>, @"order_date",
<string>, @"twitter_handle",
<boolean>, @"address_verified",
<string>, @"google_handle",
<string>, @"cart_flag",
<string>, @"instagram_handle",
<string>, @"order_status",
<string>, @"latitude",
<double>, @"order_total",
<string>, @"longitude",
<double>, @"sub_total",
<double>, @"shipping_total",
<string>, @"first_name",
<double>, @"tax_total",
<double>, @"discount_total",
<string>, @"last_name",
<string>, @"address",
<double>, @"tip_total",
<string>, @"address2",
<string>, @"sessionID",
<string>, @"city",
<string>, @"ip_address",
<string>, @"state",
<string>, @"zip_code",
<string>, @"country",
<string>, @"phone_number",
<string>, @"mobile_number",
<string>, @"order_note",
<string>, @"email",
<string>, @"order_type",
<double>, @"flag_paid",
<string>, @"password",
<double>, @"flag_verified",
<string>, @"device_type",
<double>, @"flag_pulled",
<double>, @"flag_shipped",
<string>, @"passbook_enabled",
<double>, @"flag_completed",
<string>, @"wallet_enabled",
<double>, @"flag_followup",
<string>, @"opt_in_email",
<double>, @"flag_returned",
<string>, @"opt_in_sms",
<double>, @"flag_modified",
<string>, @"opt_in_updates",
<dateTime>, @"flag_paid_date",
<dateTime>, @"flag_verified_date",
<double>, @"user_no",
<string>, @"company_name",
<dateTime>, @"flag_pulled_date",
<dateTime>, @"birthdate",
<dateTime>, @"flag_shipped_date",
<dateTime>, @"flag_completed_date",
<dateTime>, @"modified_on",
<string>, @"address3",
<dateTime>, @"flag_followup_date",
<string>, @"customer_reference",
<dateTime>, @"flag_returned_date",
<string>, @"facebook_id",
<dateTime>, @"flag_modified_date",
<double>, @"affiliate_no",
<string>, @"twitter_id",
<string>, @"google_id",
<string>, @"instagram_id",
<string>, @"middle_name",
<string>, @"website",
<string>, @"customer_type", nil];
NSDictionary *finalDic = [NSDictionary dictionaryWithObjectsAndKeys:
authDic, @"auth",orderDic, @"order", nil];
NSMutableDictionary* jsonString = nil;
jsonString = [NSJSONSerialization JSONObjectWithData: findalDic options:NSJSONReadingMutableContainers];
NSMutableData *bodyData = [NSMutableData dataWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
NSString *urlString = @"https://api.peoplevine.com/commerce.asmx/generateQuote";
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:urlString]];
[request setTimeOutSeconds:250];
[request setRequestMethod:@"POST"];
[request addRequestHeader:@"Content-Type" value:@"application/json"];
[request addRequestHeader:[NSString stringWithFormat:@"%d",bodyData.length] value:@"Content-length"];
[request setPostBody:bodyData];
[request startSynchronous];
NSDictionary *responseDic = (NSDictionary*)[request.responseString JSONValue];
if (responseDic || [responseDic objectForKey:@"d"])
{
NSMutableDictionary *dicSave=[responseDic objectForKey:@"d"];
// -------------------------------------------------------------------
// convert into the data and NSUTF8StringEncoding
// -------------------------------------------------------------------
NSString *strDic=[dicSave copy];
NSMutableDictionary *dirJson;
if (strDic)
{
NSData* dataFile=[strDic dataUsingEncoding:NSUTF8StringEncoding];
NSString* newStr = [[NSString alloc] initWithData:dataFile
encoding:NSUTF8StringEncoding];
dirJson = [newStr JSONValue] ;
}
// -------------------------------------------------------------------
NSString *str=[[dirJson objectForKey:@"returnObject"]valueForKey:@"customer_no"];
}
else
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error" message:@"An Error Occurred" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
}
require 'net/http'
uri = URI('https://peoplevine.azure-api.net/customer/customer/registerCustomer')
uri.query = URI.encode_www_form({
# Specify your subscription key
'subscription-key' => '',
})
request = Net::HTTP::Post.new(uri.request_uri)
# Basic Authorization Sample
# request.basic_auth 'username', 'password'
request['Content-type'] = 'application/json'
request.body = ""
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
# Basic Authorization Sample
# 'Authorization': 'Basic %s' % base64.encodestring('{username}:{password}'),
'Content-type': 'application/json',
}
params = urllib.urlencode({
# Specify your subscription key
'subscription-key': '',
})
try:
conn = httplib.HTTPSConnection('peoplevine.azure-api.net')
conn.request("POST", "/customer/customer/registerCustomer?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Basic Authorization Sample
# 'Authorization': 'Basic %s' % base64.encodestring('{username}:{password}'),
'Content-type': 'application/json',
}
params = urllib.parse.urlencode({
# Specify your subscription key
'subscription-key': '',
})
try:
conn = http.client.HTTPSConnection('peoplevine.azure-api.net')
conn.request("POST", "/customer/customer/registerCustomer?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
@ECHO OFF
REM for Basic Authorization use: --user {username}:{password}
REM Specify values for path parameters (shown as {...}), your subscription key and values for query parameters
curl -v -X POST "https://peoplevine.azure-api.net/customer/customer/registerCustomer?subscription-key="^
-H "Content-Type: application/json"