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.



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

def user
  @user
end

Instance Method Details

#perform(user_key) ⇒ Object



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

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