diff --git a/lib/help_scout.rb b/lib/help_scout.rb index 872275c..cb9da80 100644 --- a/lib/help_scout.rb +++ b/lib/help_scout.rb @@ -115,7 +115,6 @@ def reports_user_ratings(user_id, rating, start_date, end_date, options) get("reports/user/ratings", options) end - # Public: Creates conversation thread # # conversion_id - conversation id @@ -138,6 +137,16 @@ def create_thread(conversation_id:, thread:, imported: nil, reload: nil) last_response.code == HTTP_CREATED end + # Public: Update Customer + # + # id - customer id + # data - hash with data + # + # More info: http://developer.helpscout.net/help-desk-api/customers/update/ + def update_customer(id, data) + put("customers/#{id}", { body: data }) + end + protected def post(path, options = {}) diff --git a/spec/helpscout_spec.rb b/spec/helpscout_spec.rb index 84697e3..eb01f5f 100644 --- a/spec/helpscout_spec.rb +++ b/spec/helpscout_spec.rb @@ -112,4 +112,18 @@ expect(req).to have_been_requested end end + + describe '#update_customer' do + let(:data) { { "firstName" => "Bob" } } + + it 'does the correct query' do + url = 'https://api.helpscout.net/v1/customers/1337.json' + req = stub_request(:put, url). + with(body: data.to_json). + to_return(status: 201) + + client.update_customer(1337, data) + expect(req).to have_been_requested + end + end end