{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"params":[],"settings":""},"next":{"description":"","pages":[]},"title":"DevMate API Libraries","type":"basic","slug":"devmate-api-libraries","excerpt":"","body":"Our open-source libraries are aimed to improve your working experience with DevMate API. At the moment there are Python and Java libraries available. \n[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"If you've created your own library and would like to share with DevMate community, please [let us know](mailto:support:::at:::devmate.com).\"\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Java\"\n}\n[/block]\nDevMate API Client on Java: https://github.com/DevMate/DevMateClientJava\n\n[Getting Started](https://github.com/DevMate/DevMateClientJava#getting-started)\n\nHow to include library to your project: \n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"<dependency>\\n <groupId>com.devmate.pub</groupId>\\n <artifactId>client</artifactId>\\n <version>1.0.2</version>\\n</dependency>\\n\",\n \"language\": \"java\",\n \"name\": \"For Maven\"\n }\n ]\n}\n[/block]\n\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"compile group: 'com.devmate.pub', name: 'client', version: '1.0.2'\\n\",\n \"language\": \"java\",\n \"name\": \"For Gradle\"\n }\n ]\n}\n[/block]\n \n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"// DevMate public API token\\n// You can generate it in Settings -> API Integration\\nfinal String token = \\\"1234567890abcdef\\\";\\n\\n// Initialize client with builder\\nDevMateClient devMateClient = DevMateClientBuilder.buildDefault(token);\\n\\n// Get single customer by ID\\nint someId = 123;\\n// Data container with target object and meta data\\nData<Customer, CustomersMeta> singleCustomerData = devMateClient\\n .customers()\\n .getCustomerById(someId);\\n\\nCustomer singleCustomer = singleCustomerData.getData();\\n\\n// Update customer details\\nCustomer customerWithNewDetails = Customer.newBuilder(singleCustomer)\\n .firstName(\\\"New Name\\\")\\n .note(\\\"Something new\\\")\\n .build();\\n\\n// Returns updated data\\nData<Customer, CustomersMeta> updatedCustomerData = devMateClient\\n .customers()\\n .updateCustomer(customerWithNewDetails);\\n\\n// Create new customer\\nCustomer createdCustomer = devMateClient\\n .customers()\\n .createCustomer(Customer.newBuilder()\\n .email(\\\"[email protected]\\\")\\n .firstName(\\\"Dead\\\")\\n .lastName(\\\"Beef\\\")\\n .build())\\n .getData();\\n\\n// Create new license for customer\\n// License Type ID is needed, you can find it in Product -> Settings -> License Types -> ID (details field)\\nint customerId = createdCustomer.getId();\\nint licenseTypeId = 123;\\n\\nLicense license = devMateClient\\n .customers()\\n .createLicenseForCustomer(customerId, License.newBuilder()\\n .licenseTypeId(licenseTypeId)\\n .build())\\n .getData();\\n\\n// Now you can get created license info, e.g. activation key\\nString activationKey = license.getActivationKey();\\n\\n// Get list of customers with filter parameters\\nData<List<Customer>, CustomersMeta> customersData = devMateClient\\n .customers()\\n .getCustomers(with()\\n .firstNameContains(\\\"Dea\\\")\\n .key(activationKey)\\n .limit(20)\\n .includeLicenses(true));\\n\\nint totalCustomers = customersData.getMeta().getTotal();\\n\\n// Reset first activation by activation key\\ndevMateClient.licenses().resetFirstActivation(activationKey);\\n\\n// Close the DevMate client\\ndevMateClient.close();\\n\",\n \"language\": \"java\",\n \"name\": \"Usage Example\"\n }\n ]\n}\n[/block]\n \n \n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Python\"\n}\n[/block]\nDevMate API Client on Python: https://github.com/DevMate/DevMateClientPython\n\n[Getting Started:](https://github.com/DevMate/DevMateClientPython#installation)\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"pip install devmateclient\",\n \"language\": \"text\",\n \"name\": \"The latest stable version is always available on PyPi.\"\n }\n ]\n}\n[/block]\n\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"# DevMate public API token\\n# You can generate it in Settings -> API Integration\\ntoken = '1234567890abcdef'\\n\\n# Initialize client with token\\ndm_client = devmateclient.Client(auth_token=token)\\n\\n# You still have an access to the token\\nold_token = dm_client.auth_token\\n\\n# Or you can change it in runtime\\ndm_client.auth_token = '0987654321abcdef'\\n\\n# Get single customer by ID\\ncustomer = dm_client.get_customer_by_id(123)\\n\\n# Create new customer in DevMate (email is required)\\ncustomer_details = {\\n 'email': '[email protected]',\\n 'first_name': 'Dead',\\n 'last_name': 'Beef'\\n}\\ncreated_customer = dm_client.create_customer(customer_details)\\n\\n# Update existing customer in DevMate (id is required)\\ncustomer_update_details = dict(created_customer)\\ncustomer_update_details['company'] = 'Some Company'\\nupdated_customer = dm_client.update_customer(customer_update_details)\\n\\n# Create new license for customer (license_type_id is required)\\nnew_license = dm_client.create_license_for_customer(\\n customer_id=123, \\n _license={'license_type_id': 1}\\n)\\n# Now you can get created license info, e.g. activation key\\nactivation_key = new_license['activation_key']\\n\\n# Get list of customers with filter parameters and additional meta data (returns tuple)\\n# Don't set with_meta to return only customers\\ncustomers, meta = dm_client.get_customers(with_email='[email protected]',\\n with_key=activation_key,\\n with_limit=20,\\n with_licenses=True,\\n with_meta=True)\\n\\n# Reset first activation by activation key\\ndm_client.reset_first_activation(activation_key)\\n\\n# Close the DevMate client\\ndm_client.close()\",\n \"language\": \"python\",\n \"name\": \"Usage Example\"\n }\n ]\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"\"\n}\n[/block]\nShould you have any questions on these libraries, you're welcome to [contact us](mailto:[email protected]).","updates":[],"order":6,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"57d926b9da17c30e00389758","createdAt":"2016-09-14T10:30:17.053Z","user":"573dd709b3f88f0e00dcae1f","__v":0,"githubsync":"","parentDoc":null,"project":"547cd7662eaee50800ed1089","version":{"version":"1.0","version_clean":"1.0.0","codename":"","is_stable":false,"is_beta":false,"is_hidden":false,"is_deprecated":true,"categories":["547cd7672eaee50800ed108d","54c8f8ae0174630d00efa874","54c8f8bd7a11f60d0022a832","54c8f8c60174630d00efa876","54c8f8f10174630d00efa877","55155826bc466623002afe83","551558324c7c1e39003735a0","56052058e266000d008971c7","57909a453b845d0e006a37d5"],"_id":"547cd7662eaee50800ed108c","createdAt":"2014-12-01T21:02:30.851Z","project":"547cd7662eaee50800ed1089","releaseDate":"2014-12-01T21:02:30.851Z","__v":9},"category":{"sync":{"isSync":false,"url":""},"pages":["5605215df6b86e0d00284ab5","56052995d5c3900d0003e83d","56056243e266000d0089720e","56056496f6b86e0d00284b09","56094876c5cff70d007d016a","5609493a31beb60d001b65d9","56094af131beb60d001b65db"],"title":"Public API","slug":"public-api","order":8,"from_sync":false,"reference":false,"_id":"56052058e266000d008971c7","project":"547cd7662eaee50800ed1089","__v":7,"createdAt":"2015-09-25T10:22:16.805Z","version":"547cd7662eaee50800ed108c"}}