Sign up

Collections

Listing email addresses

  • Python
  • Php
  • Java
  • C#
  • Javascript
from greendizer import BuyerClient
            
user = BuyerClient(oauth_token="oauth_token").user

#Initialize a collection instance
collection = user.emails.all        #You can use the search() with a query  
                                    #instead to filter the resources.

#Call the populate method to fill the collection
collection.populate()

#Access the loaded elements
print collection.resources
require_once 'Greendizer/BuyerClient.php';

$buyerClient = new Greendizer_BuyerClient(array('token' => $oauth_token));
$user = $buyerClient->getUser();

//Instantiate a collection
$collection = $user->emails()->getAll();	//You can use the search() with a query  
                                    			 	//Instead to filter the resources.

//Call the populate method to fill the collection
$collection->populate();

//Access the loaded elements
print $collection->getResources();
import com.greendizer.api.client.BuyerClient;
import com.greendizer.api.resource.buyer.Email;
import com.greendizer.api.dal.Collection;

Buyer buyer = new BuyerClient("oauth_token").getUser();

//You can use the search() with a query
//instead to filter the resources
Collection<Email> collection = buyer.getEmails().all();

//Call the populate method to fill the collection
collection.populate();

//Print the emails
System.out.println(collection);

using Greendizer;
using Greendizer.Buyers;

//Instantiate a buyer Client instance
var client = new BuyerClient("jimi.hendrix@springshield.com", "jimispassword");

//Gets the user as a buyer instance
var buyer = (Buyer)client.User;

//Retrieve all the email addresses attached to the current user.
var emails = buyer.Emails.All;
emails.Populate();

//Gets the list of retrieved email addresses.
var resources = emails.Resources;
application.init(function(state, error){
    if(state){
        //Initialize a collection
        var collection = application.getUser().getEmails().getAll();    //You can use the search() 
                                                                        //method with a query instead 
                                                                        //to filter the resources.
        
        //Call the populate() method to fill the collection                                                               
        collection.populate(function(){
            //Print the emails                  
            console.log(collection.getResources());      
        }, function(response){                          
            console.error("Could not load the list of email addresses");
        });
    }
});

Listing invoices

  • Python
  • Php
  • Java
  • C#
  • Javascript
from greendizer import BuyerClient
            
user = BuyerClient(oauth_token="oauth_token").user

#Initialize an email instance with the address to which the invoices were sent.
email = user.emails["jimi.hendrix@springshield.com"]

#Initialize a collection for the invoices
collection = email.invoices.all         #again, we could have used the search()
                                        #instead to filter the results
                                            
#Call the populate method to fill the collection
collection.populate()

#Access the loaded elements
print collection.resources
require_once 'Greendizer/BuyerClient.php';

$buyerClient = new Greendizer_BuyerClient(array('token' => $oauth_token));
$user = $buyerClient->getUser();

//Initialize an email instance with the address to which the invoices were sent.
$email = $user->emails()->getById('jimi.hendrix@springshield.com');

//Initialize a collection for the invoices
$collection = $email->invoices()->getAll();		 //again, we could have used the search()
                                    			 //instead to filter the results

//Call the populate method to fill the collection
$collection->populate();

//Access the loaded elements
print $collection->getResources();
import com.greendizer.api.client.BuyerClient;
import com.greendizer.api.resource.buyer.Email;
import com.greendizer.api.resource.buyer.Invoice;
import com.greendizer.api.dal.Collection;

Buyer buyer = new BuyerClient("oauth_token").getUser();

//Initialize an email instance with the address to which the invoices were sent
Email email = buyer.getEmails().getById("jimi.hendrix@springshield.com");

//We could have used the search()
//instead to filter the results
Collection<Invoice> collection = email.getInvoices().all();

//Call the populate method to fill the collection
collection.populate();

//Print the invoices
System.out.println(collection);

using Greendizer;
using Greendizer.Buyers;

//Instantiate a buyer Client instance
var client = new BuyerClient("jimi.hendrix@springshield.com", "jimispassword");

//Gets the current User as a Buyer instance
var buyer = (Buyer)client.User;

//Retrieves all the invoices addressed to "jimi.hendrix@springshield.com"
var invoices = buyer.Emails["jimi.hendrix@springshield.com"].Invoices.All;
invoices.Populate();

//Gets the list of retrieved invoices
var resources = invoices.Resources;
application.init(function(state, error){
    if(state){
        //Initialize an email instance with the address to which the invoices were sent.
        var email = application.getUser().getEmails().getItemByID("jimi.hendrix@springshield.com");
        
        //Initialize a collection for the invoices
        var collection = email.invoices.getAll();   //again, you could have used the search() 
                                                    //method with a query instead to filter
                                                    //the resources. 
        
        //Call the populate() method to fill the collection                                                               
        collection.populate(function(){
            //Print the invoices                  
            console.log(collection.getResources());      
        }, function(response){                          
            console.error("Could not load the list of invoices sent to jimi.hendrix@springshield.com");
        });
    }
});

Email

The email object represents a user's email address.

  • Python
  • Php
  • Java
  • C#
  • Javascript
from greendizer import BuyerClient
            
user = BuyerClient(oauth_token="oauth_token").user

email = user.emails["jimi.hendrix@springshield.com"]

#Print details about the email
print email.label
require_once 'Greendizer/BuyerClient.php';

$buyerClient = new Greendizer_BuyerClient(array('token' => $oauth_token));
$user = $buyerClient->getUser();

$email = $user->emails()->getById('jimi.hendrix@springshield.com');

//Print details about the email
echo $email->getLabel();
import com.greendizer.api.resource.buyer.Buyer;
import com.greendizer.api.resource.buyer.Email;
                        
Buyer buyer = new BuyerClient("oauth_client").getUser();

Email email = buyer.getEmails().getById("jimi.hendrix@springshield.com");

//Print details about the email
System.out.println("email.getLabel()");
application.init(function(state, error){
    if(state){
        var emails = application.getUser().getEmails();
        emails.getItemById("jimi.hendrix@springshield.com", function(email){
            //Print details about the email
            console.log(email.getLabel());
        }, function(response){
            console.log("Unable to load the email email address");
        });
    }
});

Invoice

Represents an invoice received by the buyer.

  • Python
  • Php
  • Java
  • C#
  • Javascript
from greendizer import BuyerClient
            
user = BuyerClient(oauth_token="oauth_token").user

#Initialize an email instance with the address to which the invoice was sent
email = user.emails["jimi.hendrix@springshield.com"]

invoice = email.invoices["1234567890"]

#Access to details about the invoice
print invoice.due_date
print invoice.currency
print invoice.total
require_once 'Greendizer/BuyerClient.php';

$buyerClient = new Greendizer_BuyerClient(array('token' => $oauth_token));
$user = $buyerClient->getUser();

//Initialize an email instance with the address to which the invoice was sent
$email = $user->emails()->getById('jimi.hendrix@springshield.com');

$invoice = $email->invoices()->getById("1234567890");

//Access to details about the invoice
echo $invoice->getDueDate();
echo $invoice->getCurrency();
echo $invoice->getTotal();
import com.greendizer.api.client.BuyerClient;
import com.greendizer.api.resource.buyer.Email;
import com.greendizer.api.resource.buyer.Invoice;

Buyer buyer = new BuyerClient("oauth_token").getUser();

//Initialize an email instance with the address to which the invoices were sent
Email email = buyer.getEmails().getById("jimi.hendrix@springshield.com");

Invoice invoice = email.getInvoices().getById("1234567890");

//Access to details about the invoice
System.out.println(invoice.getDueDate());
System.out.println(invoice.getCurrency());
System.out.println(invoice.getTotal());
application.init(function(state, error){
    if(state){
        //Initialize an email address with the address from which the invoice was sent
        var email = application.getUser().getEmails().getItemByID("jimi.hendrix@springshield.com");
        
        var invoice = email.getInvoices().getItemByID("1234567890", function(invoice){
            //Access details about the invoice
            console.log(invoice.getDueDate());
            console.log(invoice.getCurrency());
            console.log(invoice.getTotal());
        }, function(response){
            console.log("Unable to load the invoice.");
        });
    }
});