From 7bb8bb364579cef7c3ea915fc35eaa743aacf3ac Mon Sep 17 00:00:00 2001 From: Michael Groeneman Date: Mon, 16 Nov 2015 16:22:20 -0800 Subject: [PATCH] Add send_invite to Vendor API --- lib/rubill/query.rb | 4 ++++ lib/rubill/vendor.rb | 4 ++++ spec/query_spec.rb | 14 ++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/lib/rubill/query.rb b/lib/rubill/query.rb index 1f1df3f..024940f 100644 --- a/lib/rubill/query.rb +++ b/lib/rubill/query.rb @@ -57,6 +57,10 @@ def self.void_received_payment(id) execute("/VoidARPayment.json", id: id) end + def self.send_vendor_invite(vendorId, email) + execute("/SendVendorInvite.json", vendorId: vendorId, email: email) + end + def execute Session.instance.execute(self) end diff --git a/lib/rubill/vendor.rb b/lib/rubill/vendor.rb index f77c1ef..27aa4b4 100644 --- a/lib/rubill/vendor.rb +++ b/lib/rubill/vendor.rb @@ -10,5 +10,9 @@ def bills Query::Filter.new("vendorId", "=", id), ]) end + + def send_invite(email) + Query.send_vendor_invite(id, email) + end end end diff --git a/spec/query_spec.rb b/spec/query_spec.rb index 6b8ab0c..f54a888 100644 --- a/spec/query_spec.rb +++ b/spec/query_spec.rb @@ -58,5 +58,19 @@ module Rubill described_class.pay_bills(options) end end + + describe ".send_vendor_invite" do + let(:url) { "/SendVendorInvite.json" } + let(:query) { double(execute: true) } + let(:vendor_id) { '1234' } + let(:email) { 'test@email.com' } + let(:options) { Hash[vendorId: '1234', email: 'test@email.com'] } + + it "creates a new Query object and executes it" do + expect(described_class).to receive(:new).with(url, options) { query } + expect(query).to receive(:execute) + described_class.send_vendor_invite(vendor_id, email) + end + end end end