spacetraders.rb/lib/models/contract.rb

34 lines
751 B
Ruby

# frozen_string_literal: true
class SpaceTraders::Contract < SpaceTraders::Model
attributes :id, :factionSymbol, :type, :terms, :accepted, :fulfilled, :expiration, :deadlineToAccept
def self.my_contracts(client)
list = client.contracts.my_contracts
list.map { new(client, **_1) }
end
def accept!
client.contracts.my_contracts_accept(id: id) # {agent, contract}
end
def deliver!
client.contracts.my_contracts_deliver(id: id) # {agent, contract}
self
end
def fulfill!
client.contracts.my_contracts_fulfill(id: id) # {agent, contract}
self
end
# refresh the contract attributes
def reload!
client.contracts.my_contract(id: id).each { self[_1] = _2 }
self
end
def destination
end
end