Skip to content

Commit

Permalink
Merge pull request #879 from recurly/add-pobs
Browse files Browse the repository at this point in the history
Add pobs
  • Loading branch information
faiberrec authored Jan 26, 2024
2 parents b234d74 + 3cfba57 commit a7738e6
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/recurly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module Recurly
require 'recurly/sub_add_on_percentage_tier'
require 'recurly/custom_field_definition'
require 'recurly/general_ledger_account'
require 'recurly/performance_obligation'

@subdomain = nil

Expand Down
15 changes: 15 additions & 0 deletions lib/recurly/performance_obligation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Recurly
class PerformanceObligation < Resource

define_attribute_methods %w(
id
name
created_at
updated_at
)

def self.collection_path
"performance_obligations"
end
end
end
24 changes: 24 additions & 0 deletions spec/fixtures/performance_obligations/index-200.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<performance_obligations type="array">
<performance_obligation href="https://api.recurly.com/v2/performance_obligations/6">
<id>6</id>
<name>Over Time (Daily)</name>
<created_at type="datetime">2023-08-11T18:57:57Z</created_at>
<updated_at type="datetime">2023-08-11T18:57:57Z</updated_at>
</performance_obligation>
<performance_obligation href="https://api.recurly.com/v2/performance_obligations/5">
<id>5</id>
<name>Over Time (Partial Monthly)</name>
<created_at type="datetime">2023-08-11T18:57:57Z</created_at>
<updated_at type="datetime">2023-08-11T18:57:57Z</updated_at>
</performance_obligation>
<performance_obligation href="https://api.recurly.com/v2/performance_obligations/4">
<id>4</id>
<name>Point in Time</name>
<created_at type="datetime">2023-08-11T18:57:57Z</created_at>
<updated_at type="datetime">2023-08-11T18:57:57Z</updated_at>
</performance_obligation>
</performance_obligations>
10 changes: 10 additions & 0 deletions spec/fixtures/performance_obligations/show-200.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<performance_obligation href="https://api.recurly.com/v2/performance_obligations/6">
<id>6</id>
<name>Over Time (Daily)</name>
<created_at type="datetime">2023-08-11T18:57:57Z</created_at>
<updated_at type="datetime">2023-08-11T18:57:57Z</updated_at>
</performance_obligation>
33 changes: 33 additions & 0 deletions spec/recurly/performance_obligation_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'spec_helper'

describe PerformanceObligation do
let(:performance_obligation) {
stub_api_request(:get, "performance_obligations/6", "performance_obligations/show-200")
Recurly::PerformanceObligation.find '6'
}

let(:performance_obligations) {
stub_api_request(:get, "performance_obligations", "performance_obligations/index-200")
Recurly::PerformanceObligation.all
}

describe "#find" do
it "returns a PerformanceObligation" do
performance_obligation.must_be_instance_of(PerformanceObligation)
end

it "has correct attributes" do
expect(performance_obligation.id).must_equal('6')
expect(performance_obligation.name).must_equal('Over Time (Daily)')
expect(performance_obligation.created_at).wont_be_nil
end
end

describe "#index" do
describe "when no params are passed" do
it "returns a list of performance obligations" do
expect(performance_obligations.count).must_equal(3)
end
end
end
end

0 comments on commit a7738e6

Please sign in to comment.