Class: Hyrax::Arkivo::CreateSubscriptionJob

Inherits:
Hyrax::ApplicationJob show all
Defined in:
lib/hyrax/arkivo/create_subscription_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



7
8
9
# File 'lib/hyrax/arkivo/create_subscription_job.rb', line 7

def user
  @user
end

Instance Method Details

#perform(user_key) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/hyrax/arkivo/create_subscription_job.rb', line 9

def perform(user_key)
  @user = ::User.find_by_user_key(user_key)
  validate_user!

  # post json to API
  response = post_to_api
  # parse results
  subscription_path = response.headers['Location']
  # create subscription
  user.arkivo_subscription = subscription_path
  user.save
end