// Import the crate. You need the #[macro_use] or none of this will work.
// Needs to be in the crate root
extern crate foundation;
// Bring crates used into scope, use only in the crate root. Not fun part this
// will tie you to specific versions of the crates. Since we reexport stuff from
// them as part of the public API. This is cleaner than importing the huge
// amount of types yourself.
use *;
// Use this anywhere there are macros being used from foundation
use *;
// We'll need this in the code below. It's not required for foundation
extern crate serde_json;
use Value;
// Name of your client type
// A string that points to the API
// A closure that takes the below parameters (one being the name of your client
// type), that allows you to manipulate the `Request` type from Hyper. Perfect
// for setting up required headers or handling a given token value for all
// requests that are made to the API. It shouldn't return a value.
client!;
// Function used for deserialiation using this signature header. Can have
// multiple of these functions if needed (i.e. one for XML, another for JSON,
// or one for MsgPack)
// Define new types, where a type represents a part of the URL. If this part
// of the URL built up can execute a request give it a path to your
// deserialization function in order for it to work when executed.
// You can specify a type that doesn't represent a valid query, but part of
// a URL with something like this:
// new_type!(
// NotDeserializableType;
// User => string_from_bytes;
// Users => string_from_bytes;
// UsersUsername => string_from_bytes;
// )
// as part of the list.
new_type!;
// Here's where you wire everything up between the types. We know what can
// deserialize and what's just a type, but not how to go from one part of the
// URL to the other. You have a few different ways to do this. First thing is
// you name what type you want to make go to another by naming it like so:
//
// MyType {
//
// };
//
// Inside of it you can put two different types of fields:
// 1) parameter_transition
// 2) transition
//
// parameter_transition when utilized looks like this:
//
// MyType {
// parameter_transition {
// (MyType2, my_type_two, type_str)
// (MyType3, my_type_three, type_str)
// }
// };
//
// It takes a list of tuples. The first value is the type you want to go to,
// the second value is the name of the function used to make the transition,
// and the third value is the name of the parameter in the function, that shows
// up in the documentation you can generate.
//
// The transition field when utilized looks like this:
//
// MyType {
// transition {
// (MyType2, ty_two)
// (MyType3, ty_three)
// }
// };
//
// It takes a list of tuples. The first value is the type you want to go to,
// the second value is the name of the function used to make the transition and
// the string used for the URL. So if you were at https://mysite.com/ and you
// called ty_two while building up the query it becomes
// https://mysite.com/ty_two used for the URL.
//
// You can also use both together! The transition field comes before the
// parameter_transition field
// MyType {
// transition {
// (MyType2, ty_two)
// (MyType3, ty_three)
// }
//
// parameter_transition {
// (MyType4, my_type_four, type_str)
// (MyType5, my_type_five, type_str)
// }
// };
//
// You can now repeat the above pattern for every type you need. By default
// in the file you call `client!()` you get a Get, Post, Put, Patch, and Delete
// type that can be wired up to other types. You'll need to wire these up to
// whatever other types you need to or else you'll never be able to make a
// query!
make_connections!;