Our open-source libraries are aimed to improve your working experience with DevMate API. At the moment there are Python and Java libraries available.
If you've created your own library and would like to share with DevMate community, please let us know.
Java
DevMate API Client on Java: https://github.com/DevMate/DevMateClientJava
How to include library to your project:
<dependency>
<groupId>com.devmate.pub</groupId>
<artifactId>client</artifactId>
<version>1.0.2</version>
</dependency>
compile group: 'com.devmate.pub', name: 'client', version: '1.0.2'
// DevMate public API token
// You can generate it in Settings -> API Integration
final String token = "1234567890abcdef";
// Initialize client with builder
DevMateClient devMateClient = DevMateClientBuilder.buildDefault(token);
// Get single customer by ID
int someId = 123;
// Data container with target object and meta data
Data<Customer, CustomersMeta> singleCustomerData = devMateClient
.customers()
.getCustomerById(someId);
Customer singleCustomer = singleCustomerData.getData();
// Update customer details
Customer customerWithNewDetails = Customer.newBuilder(singleCustomer)
.firstName("New Name")
.note("Something new")
.build();
// Returns updated data
Data<Customer, CustomersMeta> updatedCustomerData = devMateClient
.customers()
.updateCustomer(customerWithNewDetails);
// Create new customer
Customer createdCustomer = devMateClient
.customers()
.createCustomer(Customer.newBuilder()
.email("[email protected]")
.firstName("Dead")
.lastName("Beef")
.build())
.getData();
// Create new license for customer
// License Type ID is needed, you can find it in Product -> Settings -> License Types -> ID (details field)
int customerId = createdCustomer.getId();
int licenseTypeId = 123;
License license = devMateClient
.customers()
.createLicenseForCustomer(customerId, License.newBuilder()
.licenseTypeId(licenseTypeId)
.build())
.getData();
// Now you can get created license info, e.g. activation key
String activationKey = license.getActivationKey();
// Get list of customers with filter parameters
Data<List<Customer>, CustomersMeta> customersData = devMateClient
.customers()
.getCustomers(with()
.firstNameContains("Dea")
.key(activationKey)
.limit(20)
.includeLicenses(true));
int totalCustomers = customersData.getMeta().getTotal();
// Reset first activation by activation key
devMateClient.licenses().resetFirstActivation(activationKey);
// Close the DevMate client
devMateClient.close();
Python
DevMate API Client on Python: https://github.com/DevMate/DevMateClientPython
pip install devmateclient
# DevMate public API token
# You can generate it in Settings -> API Integration
token = '1234567890abcdef'
# Initialize client with token
dm_client = devmateclient.Client(auth_token=token)
# You still have an access to the token
old_token = dm_client.auth_token
# Or you can change it in runtime
dm_client.auth_token = '0987654321abcdef'
# Get single customer by ID
customer = dm_client.get_customer_by_id(123)
# Create new customer in DevMate (email is required)
customer_details = {
'email': '[email protected]',
'first_name': 'Dead',
'last_name': 'Beef'
}
created_customer = dm_client.create_customer(customer_details)
# Update existing customer in DevMate (id is required)
customer_update_details = dict(created_customer)
customer_update_details['company'] = 'Some Company'
updated_customer = dm_client.update_customer(customer_update_details)
# Create new license for customer (license_type_id is required)
new_license = dm_client.create_license_for_customer(
customer_id=123,
_license={'license_type_id': 1}
)
# Now you can get created license info, e.g. activation key
activation_key = new_license['activation_key']
# Get list of customers with filter parameters and additional meta data (returns tuple)
# Don't set with_meta to return only customers
customers, meta = dm_client.get_customers(with_email='some@e',
with_key=activation_key,
with_limit=20,
with_licenses=True,
with_meta=True)
# Reset first activation by activation key
dm_client.reset_first_activation(activation_key)
# Close the DevMate client
dm_client.close()
Should you have any questions on these libraries, you're welcome to contact us.