diff --git a/lib/chartmogul/customer.rb b/lib/chartmogul/customer.rb index e3e9525..772ff07 100644 --- a/lib/chartmogul/customer.rb +++ b/lib/chartmogul/customer.rb @@ -36,6 +36,7 @@ class Customer < APIResource writeable_attr :free_trial_started_at, type: :time writeable_attr :owner writeable_attr :primary_contact + writeable_attr :website_url include API::Actions::Create include API::Actions::Custom diff --git a/spec/chartmogul/customer_spec.rb b/spec/chartmogul/customer_spec.rb index a0e8095..7c55f60 100644 --- a/spec/chartmogul/customer_spec.rb +++ b/spec/chartmogul/customer_spec.rb @@ -19,7 +19,8 @@ lead_created_at: Time.utc(2016, 10, 1).to_s, free_trial_started_at: Time.utc(2016, 10, 2).to_s, owner: 'owner@chartmogul.com', - custom: { Toggle: false } + custom: { Toggle: false }, + website_url: 'example.com' } end let(:customer_uuid) { 'cus_23e01538-2c7e-11ee-b2ce-fb986e96e21b' } @@ -50,7 +51,8 @@ lead_created_at: Time.utc(2016, 10, 1).to_s, free_trial_started_at: Time.utc(2016, 10, 2).to_s, owner: 'owner@chartmogul.com', - status: nil + status: nil, + website_url: 'example.com' ) end end @@ -73,7 +75,8 @@ lead_created_at: Time.utc(2016, 10, 1), free_trial_started_at: Time.utc(2016, 10, 2), owner: 'owner@chartmogul.com', - status: 'Active' + status: 'Active', + website_url: 'example.com' ) end end @@ -101,7 +104,8 @@ uuid: customer_uuid, data_source_uuid: data_source_uuid, email: 'customer@example.com', - external_id: 'cus_004' + external_id: 'cus_004', + website_url: 'https://chartmogul.com' ) end @@ -112,7 +116,8 @@ name: 'New Customer', email: 'new_customer@example.com', owner: 'bruno+chartmogultest@chartmogul.com', - city: 'Berlin' + city: 'Berlin', + website_url: 'https://chartmogul.com' } customer = described_class.create!(**attributes) expect(customer).to have_attributes( @@ -132,6 +137,7 @@ customer.city = 'Berlin' customer.lead_created_at = Time.utc(2016, 1, 1, 14, 30) customer.free_trial_started_at = Time.utc(2016, 2, 2, 22, 40) + customer.website_url = 'https://chartmogul.com' customer.attributes = {}.tap do |att| att[:tags] = [:wurst] att[:custom] = { Toggle: true } @@ -156,13 +162,15 @@ email: 'customer_test@example.com', company: 'Curry 42', attributes: { custom: { Toggle: true } }, - name: 'Test Customer' + name: 'Test Customer', + website_url: 'https://example.co' }) expect(updated_customer).to have_attributes( email: 'customer_test@example.com', company: 'Curry 42', name: 'Test Customer', + website_url: 'https://example.co', attributes: { custom: { Toggle: true }, clearbit: {}, tags: ["wurst"], stripe: {} diff --git a/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/creates_the_customer_correctly.yml b/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/creates_the_customer_correctly.yml index 8d6d231..703f163 100644 --- a/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/creates_the_customer_correctly.yml +++ b/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/creates_the_customer_correctly.yml @@ -29,9 +29,9 @@ http_interactions: connection: - keep-alive body: - encoding: ASCII-8BIT - string: !binary |- - eyJpZCI6MTMzMTQ5MTQ1LCJ1dWlkIjoiY3VzX2E0NjgwYTljLTc2YTQtMTFlZS04M2FiLWQzYjlhYWJjN2YwMCIsImV4dGVybmFsX2lkIjoiY3VzXzAwNyIsIm5hbWUiOiJOZXcgQ3VzdG9tZXIiLCJlbWFpbCI6Im5ld19jdXN0b21lckBleGFtcGxlLmNvbSIsInN0YXR1cyI6Ik5ldyBMZWFkIiwiY3VzdG9tZXItc2luY2UiOm51bGwsImF0dHJpYnV0ZXMiOnsiY3VzdG9tIjp7fSwiY2xlYXJiaXQiOnt9LCJzdHJpcGUiOnt9LCJ0YWdzIjpbXX0sImRhdGFfc291cmNlX3V1aWQiOiJkc18wM2NmZDJjNC0yYzdlLTExZWUtYWIyMy1jYjBmMDA4Y2ZmNDYiLCJkYXRhX3NvdXJjZV91dWlkcyI6WyJkc18wM2NmZDJjNC0yYzdlLTExZWUtYWIyMy1jYjBmMDA4Y2ZmNDYiXSwiZXh0ZXJuYWxfaWRzIjpbImN1c18wMDciXSwiY29tcGFueSI6IiIsImNvdW50cnkiOm51bGwsInN0YXRlIjpudWxsLCJjaXR5IjoiQmVybGluIiwiemlwIjpudWxsLCJsZWFkX2NyZWF0ZWRfYXQiOm51bGwsImZyZWVfdHJpYWxfc3RhcnRlZF9hdCI6bnVsbCwiYWRkcmVzcyI6eyJjb3VudHJ5IjpudWxsLCJzdGF0ZSI6bnVsbCwiY2l0eSI6IkJlcmxpbiIsImFkZHJlc3NfemlwIjpudWxsfSwibXJyIjowLCJhcnIiOjAsImJpbGxpbmctc3lzdGVtLXVybCI6bnVsbCwiY2hhcnRtb2d1bC11cmwiOiJodHRwczovL2FwcC5jaGFydG1vZ3VsLmNvbS8jL2N1c3RvbWVycy8xMzMxNDkxNDUtTmV3X0N1c3RvbWVyIiwiYmlsbGluZy1zeXN0ZW0tdHlwZSI6Ikdvb2dsZSBTaGVldHMiLCJjdXJyZW5jeSI6IkVVUiIsImN1cnJlbmN5LXNpZ24iOiLigqwiLCJvd25lciI6ImJydW5vK2NoYXJ0bW9ndWx0ZXN0QGNoYXJ0bW9ndWwuY29tIn0= + encoding: UTF-8 + string: + '{"id":133149145,"uuid":"cus_a4680a9c-76a4-11ee-83ab-d3b9aabc7f00","external_id":"cus_007","name":"New Customer","email":"new_customer@example.com","status":"New Lead","customer-since":null,"attributes":{"custom":{},"clearbit":{},"stripe":{},"tags":[]},"data_source_uuid":"ds_03cfd2c4-2c7e-11ee-ab23-cb0f008cff46","data_source_uuids":["ds_03cfd2c4-2c7e-11ee-ab23-cb0f008cff46"],"external_ids":["cus_007"],"company":"","country":null,"state":null,"city":"Berlin","zip":null,"lead_created_at":null,"free_trial_started_at":null,"address":{"country":null,"state":null,"city":"Berlin","address_zip":null},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#/customers/133149145-New_Customer","billing-system-type":"Google Sheets","currency":"EUR","currency-sign":"€","owner":"bruno+chartmogultest@chartmogul.com","website_url":"https://chartmogul.com"}' http_version: recorded_at: Sun, 29 Oct 2023 21:46:40 GMT recorded_with: VCR 5.1.0 diff --git a/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/retrieves_the_customer_correctly.yml b/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/retrieves_the_customer_correctly.yml index 2f7c250..6307657 100644 --- a/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/retrieves_the_customer_correctly.yml +++ b/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/retrieves_the_customer_correctly.yml @@ -29,9 +29,9 @@ http_interactions: connection: - keep-alive body: - encoding: ASCII-8BIT - string: !binary |- - eyJpZCI6MTE0MTY3NDUyLCJ1dWlkIjoiY3VzXzIzZTAxNTM4LTJjN2UtMTFlZS1iMmNlLWZiOTg2ZTk2ZTIxYiIsImV4dGVybmFsX2lkIjoiY3VzXzAwNCIsIm5hbWUiOiJSaWNoYXJkIEhlbmRyaWNrcyIsImVtYWlsIjoiY3VzdG9tZXJAZXhhbXBsZS5jb20iLCJzdGF0dXMiOiJOZXcgTGVhZCIsImN1c3RvbWVyLXNpbmNlIjpudWxsLCJhdHRyaWJ1dGVzIjp7ImN1c3RvbSI6e30sImNsZWFyYml0Ijp7fSwic3RyaXBlIjp7fSwidGFncyI6WyJtYW5hZ2VkIl19LCJkYXRhX3NvdXJjZV91dWlkIjoiZHNfMDNjZmQyYzQtMmM3ZS0xMWVlLWFiMjMtY2IwZjAwOGNmZjQ2IiwiZGF0YV9zb3VyY2VfdXVpZHMiOlsiZHNfMDNjZmQyYzQtMmM3ZS0xMWVlLWFiMjMtY2IwZjAwOGNmZjQ2Il0sImV4dGVybmFsX2lkcyI6WyJjdXNfMDA0Il0sImNvbXBhbnkiOiJQaWVkIFBpcGVyIiwiY291bnRyeSI6IlVTIiwic3RhdGUiOiJDQSIsImNpdHkiOiJTYW4gRnJhbmNpc2NvIiwiemlwIjoiMTIzNDUiLCJsZWFkX2NyZWF0ZWRfYXQiOiIyMDE1LTExLTAxVDAwOjAwOjAwLjAwMFoiLCJmcmVlX3RyaWFsX3N0YXJ0ZWRfYXQiOiIyMDE1LTExLTA3VDAxOjIwOjAwLjAwMFoiLCJhZGRyZXNzIjp7ImNvdW50cnkiOiJVbml0ZWQgU3RhdGVzIiwic3RhdGUiOiJDYWxpZm9ybmlhIiwiY2l0eSI6IlNhbiBGcmFuY2lzY28iLCJhZGRyZXNzX3ppcCI6IjEyMzQ1In0sIm1yciI6MCwiYXJyIjowLCJiaWxsaW5nLXN5c3RlbS11cmwiOm51bGwsImNoYXJ0bW9ndWwtdXJsIjoiaHR0cHM6Ly9hcHAuY2hhcnRtb2d1bC5jb20vIy9jdXN0b21lcnMvMTE0MTY3NDUyLVBpZWRfUGlwZXIiLCJiaWxsaW5nLXN5c3RlbS10eXBlIjoiR29vZ2xlIFNoZWV0cyIsImN1cnJlbmN5IjoiRVVSIiwiY3VycmVuY3ktc2lnbiI6IuKCrCIsIm93bmVyIjpudWxsfQ== + encoding: UTF-8 + string: + '{"id":114167452,"uuid":"cus_23e01538-2c7e-11ee-b2ce-fb986e96e21b","external_id":"cus_004","name":"Richard Hendricks","email":"customer@example.com","status":"New Lead","customer-since":null,"attributes":{"custom":{},"clearbit":{},"stripe":{},"tags":["managed"]},"data_source_uuid":"ds_03cfd2c4-2c7e-11ee-ab23-cb0f008cff46","data_source_uuids":["ds_03cfd2c4-2c7e-11ee-ab23-cb0f008cff46"],"external_ids":["cus_004"],"company":"Pied Piper","country":"US","state":"CA","city":"San Francisco","zip":"12345","lead_created_at":"2015-11-01T00:00:00.000Z","free_trial_started_at":"2015-11-07T01:20:00.000Z","address":{"country":"United States","state":"California","city":"San Francisco","address_zip":"12345"},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#/customers/114167452-Pied_Piper","billing-system-type":"Google Sheets","currency":"EUR","currency-sign":"€","owner":null,"website_url":"https://chartmogul.com"}' http_version: recorded_at: Sun, 29 Oct 2023 21:45:25 GMT recorded_with: VCR 5.1.0 diff --git a/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/updates_customer_correctly_with_the_class_method.yml b/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/updates_customer_correctly_with_the_class_method.yml index 8e86e7c..9dd2189 100644 --- a/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/updates_customer_correctly_with_the_class_method.yml +++ b/spec/fixtures/vcr_cassettes/ChartMogul_Customer/API_Actions/updates_customer_correctly_with_the_class_method.yml @@ -30,9 +30,9 @@ http_interactions: connection: - keep-alive body: - encoding: ASCII-8BIT - string: !binary |- - eyJpZCI6MTMzMTQ5MTQ1LCJ1dWlkIjoiY3VzX2E0NjgwYTljLTc2YTQtMTFlZS04M2FiLWQzYjlhYWJjN2YwMCIsImV4dGVybmFsX2lkIjoiY3VzXzAwNyIsIm5hbWUiOiJUZXN0IEN1c3RvbWVyIiwiZW1haWwiOiJjdXN0b21lcl90ZXN0QGV4YW1wbGUuY29tIiwic3RhdHVzIjoiTmV3IExlYWQiLCJjdXN0b21lci1zaW5jZSI6bnVsbCwiYXR0cmlidXRlcyI6eyJjdXN0b20iOnsiVG9nZ2xlIjp0cnVlfSwiY2xlYXJiaXQiOnt9LCJzdHJpcGUiOnt9LCJ0YWdzIjpbInd1cnN0Il19LCJkYXRhX3NvdXJjZV91dWlkIjoiZHNfMDNjZmQyYzQtMmM3ZS0xMWVlLWFiMjMtY2IwZjAwOGNmZjQ2IiwiZGF0YV9zb3VyY2VfdXVpZHMiOlsiZHNfMDNjZmQyYzQtMmM3ZS0xMWVlLWFiMjMtY2IwZjAwOGNmZjQ2Il0sImV4dGVybmFsX2lkcyI6WyJjdXNfMDA3Il0sImNvbXBhbnkiOiJDdXJyeSA0MiIsImNvdW50cnkiOiJERSIsInN0YXRlIjpudWxsLCJjaXR5IjoiQmVybGluIiwiemlwIjpudWxsLCJsZWFkX2NyZWF0ZWRfYXQiOiIyMDE2LTAxLTAxVDE0OjMwOjAwLjAwMFoiLCJmcmVlX3RyaWFsX3N0YXJ0ZWRfYXQiOiIyMDE2LTAyLTAyVDIyOjQwOjAwLjAwMFoiLCJhZGRyZXNzIjp7ImNvdW50cnkiOiJHZXJtYW55Iiwic3RhdGUiOm51bGwsImNpdHkiOiJCZXJsaW4iLCJhZGRyZXNzX3ppcCI6bnVsbH0sIm1yciI6MCwiYXJyIjowLCJiaWxsaW5nLXN5c3RlbS11cmwiOm51bGwsImNoYXJ0bW9ndWwtdXJsIjoiaHR0cHM6Ly9hcHAuY2hhcnRtb2d1bC5jb20vIy9jdXN0b21lcnMvMTMzMTQ5MTQ1LUN1cnJ5XzQyIiwiYmlsbGluZy1zeXN0ZW0tdHlwZSI6Ikdvb2dsZSBTaGVldHMiLCJjdXJyZW5jeSI6IkVVUiIsImN1cnJlbmN5LXNpZ24iOiLigqwiLCJvd25lciI6ImJydW5vK2NoYXJ0bW9ndWx0ZXN0QGNoYXJ0bW9ndWwuY29tIn0= + encoding: UTF-8 + string: + '{"id":133149145,"uuid":"cus_a4680a9c-76a4-11ee-83ab-d3b9aabc7f00","external_id":"cus_007","name":"Test Customer","email":"customer_test@example.com","status":"New Lead","customer-since":null,"attributes":{"custom":{"Toggle":true},"clearbit":{},"stripe":{},"tags":["wurst"]},"data_source_uuid":"ds_03cfd2c4-2c7e-11ee-ab23-cb0f008cff46","data_source_uuids":["ds_03cfd2c4-2c7e-11ee-ab23-cb0f008cff46"],"external_ids":["cus_007"],"company":"Curry 42","country":"DE","state":null,"city":"Berlin","zip":null,"lead_created_at":"2016-01-01T14:30:00.000Z","free_trial_started_at":"2016-02-02T22:40:00.000Z","address":{"country":"Germany","state":null,"city":"Berlin","address_zip":null},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#/customers/133149145-Curry_42","billing-system-type":"Google Sheets","currency":"EUR","currency-sign":"€","owner":"bruno+chartmogultest@chartmogul.com","website_url":"https://example.co"}' http_version: recorded_at: Sun, 29 Oct 2023 23:40:02 GMT recorded_with: VCR 5.1.0