Getting Price After Creating Job
Closed this issue · 2 comments
I have successfully created jobs using the following:
job = @lob.jobs.create(
from: { ... },
to: { ... },
objects: objects )
The resulting job, when raised to_yaml, shows me a valid job with id, price, and all of the info I'm after. However, when I try to retrieve its price (or any other attribute) like so:
price = job[:price]
it returns with nothing. No errors but no price either, despite the fact that I know the price was showing up correctly when I was to_yaml'ing the job. I'm relatively new to rails so I'm certain it's something very basic that I'm missing, any help would be greatly appreciated. I have tried the following:
price = job["price"] # this returns an error saying that the key doesn't exist
price = job.price # again an error saying that the attribute doesn't exist
price = job[0][:price] # another error saying that there is no key for nil
I'm stumped. Thanks for the help.
I was able to get the price of a job doing the following:
@lob = Lob(api_key: '<APIKEY>')
begin
#Get a valid address
addr = @lob.addresses.list()[0]
#Get a valid object
obj = @lob.objects()[0]
#Create the job
job = @lob.jobs.create(
from: addr['id'],
to: addr['id'],
objects: obj['id']
)
#Output the price
puts job['price']
rescue Exception => msg
puts "Handle the error here..."
puts msg
end
How strange, I've changed nothing, came back to it today and it works with both single quotes and double quotes.
job['price']
job["price"]