-
-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added AsyncAddList to Invoice #169
base: master
Are you sure you want to change the base?
Conversation
be56426
to
266833f
Compare
266833f
to
d735007
Compare
@prburke could you add the usage example to the readme? Thanks for the PR! |
7185ffc
to
df796ee
Compare
@prburke would love to get this (and any other PRs you have) merged—could you update the readme with some examples of how to use this? |
Hey @iloveitaly how is it going? I did something like this: module Commerce
module NetSuite
class AsyncJobStatus < ::Commerce::BaseJob
queue_as :low
def perform(job_id, transaction_type_class_name)
job_status = ::NetSuite::Async::Status.get(job_id: job_id)
if job_status.finished?
response = ::NetSuite::Async::WriteResponseList.get(job_id: job_id)
if response.list&.first&.status&.is_success
transaction_type_class_name.constantize.new.audit
else
::Raven.capture_message(
"Failed sending #{transaction_type_class_name} report",
extra: { message: response.list&.first&.status&.details&.first&.message }
)
end
else
::Commerce::NetSuite::AsyncJobStatus.set(wait: 10.minutes).perform_later(job_id, transaction_type_class_name)
end
end
end
end
end and I enqueue this job after send the record: def async_add_record_object
return unless first_row
job_status = record_object.class.async_add_list([record_object])
::Commerce::NetSuite::AsyncJobStatus.set(wait: 10.minutes).perform_later(job_status.job_id, self.class.name)
end |
@diegopolido could you collaborate on this PR and add some examples to the readme? Would be great to get a simplified version of what you posted above in the core readme. |
I would need @prburke permissions to add code on this PR, right? I can do on a separated PR, what do you think? |
@diegopolido if he didn't allow collaborators to add to this PR, then that would be true. A separate PR is fine—let's just link it to this one. |
Added AsyncAddList action to Invoice. Also added basic infrastructure that can be extended to support other asynchronous requests (e.g. NetSuite::Async::Status, NetSuite::Async::WriteResponseList, etc.)
Here is a simplified example of how it can be used: