Permalink
Browse files

Supporting open, close and cancel for orders.

  • Loading branch information...
1 parent 0b87d7d commit 1b06e4627ee86b3f518edab7e7734976c6d2a1f5 @alnorth committed Jul 9, 2012
Showing with 18 additions and 6 deletions.
  1. +18 −6 src/ShopifyApi/ShopifyObject.cs
@@ -68,7 +68,15 @@ public class ShopifyObject:DynamicObject {
} else if (binder.Name == "Delete" || binder.Name == "Destroy") {
Delete(args[0].ToString());
- Console.WriteLine("Blog {0} deleted ...", args[0].ToString());
+ Console.WriteLine("{0} deleted ...", args[0].ToString());
+ }
+ else if (binder.Name == "Close" || binder.Name == "Cancel" || binder.Name == "Open")
+ {
+ // Build the URL
+ string id = args[0].ToString();
+ var url = string.Format("{0}{1}/{2}/{3}.json", _baseUrl , this._objectType, id, binder.Name.ToLower());
+ Post(url, null);
+ Console.WriteLine("{0} {1} ...", binder.Name, id);
} else {
throw new InvalidDataException("Can't tell what it is you want to do - try using Save or Delete instead");
}
@@ -93,16 +101,20 @@ public class ShopifyObject:DynamicObject {
ExecuteRequest(url, "DELETE", "");
}
/// <summary>
- /// Executes an HTTP POST - which adds an item to the Shopify DB
+ /// Executes an HTTP POST to a specific path - which adds an item to the Shopify DB
/// </summary>
- dynamic Post(string json) {
- //build the URL
- var url = _baseUrl + this._objectType + ".json";
+ dynamic Post(string url, string json) {
var result = ExecuteRequest(url, "POST", json);
//the result will be a pile of JSON
//deserialize it and return
return JsonHelper.Decode(result);
-
+ }
+
+ dynamic Post(string json)
+ {
+ //build the URL
+ var url = _baseUrl + this._objectType + ".json";
+ return Post(url, json);
}
/// <summary>

0 comments on commit 1b06e46

Please sign in to comment.