Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
xpm_ruby (0.4.1)
xpm_ruby (0.5.0)
activesupport
builder
dry-types
Expand Down
11 changes: 7 additions & 4 deletions lib/xpm_ruby/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,16 @@ def delete(access_token:, xero_tenant_id:, job:)
end

# The XML structure for job.assign does not fit in a Hash
# so we need to pass in the XML directly
# so we need to pass in the XML directly.
#
# Returns the whole response — both "Status" and the "Job" describing the
# assignment XPM confirmed — rather than digging out one of them, because a
# caller checking the outcome and a caller reading the assignment both need
# it and neither can recover the other half.
def assign(access_token:, xero_tenant_id:, job_xml:)
response = Connection
Connection
.new(access_token: access_token, xero_tenant_id: xero_tenant_id)
.put(endpoint: "job.api/assign", data: job_xml)

response["Status"]
end

def applytemplate(access_token:, xero_tenant_id:, job:)
Expand Down
2 changes: 1 addition & 1 deletion lib/xpm_ruby/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module XpmRuby
VERSION = "0.4.1".freeze
VERSION = "0.5.0".freeze
end
24 changes: 18 additions & 6 deletions spec/xpm_ruby/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ module XpmRuby
VCR.use_cassette("xpm_ruby/job/assign") do
response = Job.assign(access_token: access_token, xero_tenant_id: xero_tenant_id, job_xml: job_xml)

expect(response).to eq("OK")
expect(response["Status"]).to eq("OK")
expect(response.dig("Job", "ID")).to eq("J000032")
expect(response.dig("Job", "Assigned", "Staff", "ID")).to eq("859230")
end
end
end
Expand All @@ -173,7 +175,9 @@ module XpmRuby
VCR.use_cassette("xpm_ruby/job/assign/remove") do
response = Job.assign(access_token: access_token, xero_tenant_id: xero_tenant_id, job_xml: job_xml)

expect(response).to eq("OK")
expect(response["Status"]).to eq("OK")
expect(response.dig("Job", "ID")).to eq("J000032")
expect(response.dig("Job", "Assigned")).to be_nil
end
end
end
Expand All @@ -187,7 +191,9 @@ module XpmRuby
VCR.use_cassette("xpm_ruby/job/assign/manager") do
response = Job.assign(access_token: access_token, xero_tenant_id: xero_tenant_id, job_xml: job_xml)

expect(response).to eq("OK")
expect(response["Status"]).to eq("OK")
expect(response.dig("Job", "ID")).to eq("J000032")
expect(response.dig("Job", "Manager", "ID")).to eq("859230")
end
end
end
Expand All @@ -199,7 +205,9 @@ module XpmRuby
VCR.use_cassette("xpm_ruby/job/assign/removemanager") do
response = Job.assign(access_token: access_token, xero_tenant_id: xero_tenant_id, job_xml: job_xml)

expect(response).to eq("OK")
expect(response["Status"]).to eq("OK")
expect(response.dig("Job", "ID")).to eq("J000032")
expect(response.dig("Job", "Manager")).to be_nil
end
end
end
Expand All @@ -213,7 +221,9 @@ module XpmRuby
VCR.use_cassette("xpm_ruby/job/assign/partner") do
response = Job.assign(access_token: access_token, xero_tenant_id: xero_tenant_id, job_xml: job_xml)

expect(response).to eq("OK")
expect(response["Status"]).to eq("OK")
expect(response.dig("Job", "ID")).to eq("J000032")
expect(response.dig("Job", "Partner", "ID")).to eq("859230")
end
end
end
Expand All @@ -225,7 +235,9 @@ module XpmRuby
VCR.use_cassette("xpm_ruby/job/assign/removepartner") do
response = Job.assign(access_token: access_token, xero_tenant_id: xero_tenant_id, job_xml: job_xml)

expect(response).to eq("OK")
expect(response["Status"]).to eq("OK")
expect(response.dig("Job", "ID")).to eq("J000032")
expect(response.dig("Job", "Partner")).to be_nil
end
end
end
Expand Down
Loading