README.md in hubspot-api-client-12.0.0 vs README.md in hubspot-api-client-13.0.0

- old
+ new

@@ -24,32 +24,28 @@ # Load the gem require 'hubspot-api-client' # Setup authorization Hubspot.configure do |config| - # Configure API key authorization: hapikey - config.api_key['hapikey'] = 'demo' + config.access_token = 'your_access_token' end # Get contacts basic_api = Hubspot::Crm::Contacts::BasicApi.new -basic_api.get_page(auth_names: 'hapikey') - +basic_api.get_page(auth_names: 'oauth2') ``` for new discovery classes since version 11.2 ```ruby # Load the gem require 'hubspot-api-client' -# Setup client with hapikey authorization -client = Hubspot::Client.new(api_key: 'demo') +# Setup client +client = Hubspot::Client.new(access_token: 'your_access_token') # Get contacts -basic_api = client.crm.contacts.basic_api -basic_api.get_page - +contacts = client.crm.contacts.basic_api.get_page ``` ### Usage ### Get all: @@ -60,54 +56,61 @@ all_contacts = basic_api.get_all(auth_names: 'oauth2') ``` for new discovery classes since version 11.2 ```ruby -client = Hubspot::Client(access_token: 'your_oauth2_access_token') +client = Hubspot::Client.new(access_token: 'your_oauth2_access_token') all_contacts = client.crm.contacts.basic_api.get_all ``` +You'll need to create a [private app](https://developers.hubspot.com/docs/api/private-apps) to get your access token or you can obtain OAuth2 access token. + Please note that pagination is used under the hood to get all results. ### Crm Object Schemas client usage: #### Creation ```ruby config = ::Hubspot::Crm::Schemas::Configuration.new do |config| - config.api_key = { 'hapikey' => 'your_hapikey' } - end - api_client = ::Hubspot::Crm::Schemas::ApiClient.new(config) - api = ::Hubspot::Crm::Schemas::CoreApi.new(api_client) - labels = ::Hubspot::Crm::Schemas::ObjectTypeDefinitionLabels.new(singular: 'My object', plural: 'My objects') - option = ::Hubspot::Crm::Schemas::OptionInput.new( - label: 'Option A', - value: 'A', - description: 'Choice number one', - display_order: 1, - hidden: false - ) - property = ::Hubspot::Crm::Schemas::ObjectTypePropertyCreate.new( - name: 'property001', - label: 'My object property', - group_name: 'my_object_information', - options: [option], - display_order: 2, - type: 'enumeration', - field_type: 'select' - ) - object_schema_egg = ::Hubspot::Crm::Schemas::ObjectSchemaEgg.new( - labels: labels, - required_properties: ['property001'], - searchable_properties: [], - primary_display_property: 'property001', - secondary_display_properties: [], - properties: [property], - associated_objects: ['CONTACT'], - name: 'my_object' - ) - api_response = api.create(object_schema_egg) + config.access_token = 'your_access_token' +end + +api_client = ::Hubspot::Crm::Schemas::ApiClient.new(config) +api = ::Hubspot::Crm::Schemas::CoreApi.new(api_client) +labels = ::Hubspot::Crm::Schemas::ObjectTypeDefinitionLabels.new(singular: 'My object', plural: 'My objects') + +option = ::Hubspot::Crm::Schemas::OptionInput.new( + label: 'Option A', + value: 'A', + description: 'Choice number one', + display_order: 1, + hidden: false +) + +property = ::Hubspot::Crm::Schemas::ObjectTypePropertyCreate.new( + name: 'property001', + label: 'My object property', + group_name: 'my_object_information', + options: [option], + display_order: 2, + type: 'enumeration', + field_type: 'select' +) + +object_schema_egg = ::Hubspot::Crm::Schemas::ObjectSchemaEgg.new( + labels: labels, + required_properties: ['property001'], + searchable_properties: [], + primary_display_property: 'property001', + secondary_display_properties: [], + properties: [property], + associated_objects: ['CONTACT'], + name: 'my_object' +) + +api_response = api.create(object_schema_egg) ``` ### Error handling