Class: SdrClient::Deposit::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/sdr_client/deposit/request.rb

Overview

This represents the metadata that we send to the server for doing a deposit

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label: nil, access: 'dark', download: 'none', use_statement: nil, copyright: nil, apo:, collection: nil, source_id:, catkey: nil, embargo_release_date: nil, embargo_access: 'world', embargo_download: 'world', type: 'http://cocina.sul.stanford.edu/models/object.jsonld', viewing_direction: nil, file_sets: [], files_metadata: {}) ⇒ Request

Additional metadata includes access, preserve, shelve, publish, md5, sha1 rubocop:disable Metrics/ParameterLists rubocop:disable Metrics/AbcSize

Parameters:

  • label (String) (defaults to: nil)

    the required object label

  • embargo_release_date (Time|nil) (defaults to: nil)

    when the item should be released from embargo or nil if no embargo

  • embargo_access (String) (defaults to: 'world')

    access after embargo has expired if embargoed

  • type (String) (defaults to: 'http://cocina.sul.stanford.edu/models/object.jsonld')

    (cocina.sul.stanford.edu/models/object.jsonld) the required object type.

  • file_sets (Array<FileSet>) (defaults to: [])

    the file sets to attach.

  • files_metadata (Hash<String, Hash<String, String>>) (defaults to: {})

    file name, hash of additional file metadata



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/sdr_client/deposit/request.rb', line 16

def initialize(label: nil,
               access: 'dark',
               download: 'none',
               use_statement: nil,
               copyright: nil,
               apo:,
               collection: nil,
               source_id:,
               catkey: nil,
               embargo_release_date: nil,
               embargo_access: 'world',
               embargo_download: 'world',
               type: 'http://cocina.sul.stanford.edu/models/object.jsonld',
               viewing_direction: nil,
               file_sets: [],
               files_metadata: {})
  @label = label
  @type = type
  @source_id = source_id
  @collection = collection
  @catkey = catkey
  @embargo_release_date = embargo_release_date
  @embargo_access = embargo_access
  @embargo_download = embargo_download
  @access = access
  @download = download
  @use_statement = use_statement
  @copyright = copyright
  @apo = apo
  @file_sets = file_sets
  @files_metadata = 
  @viewing_direction = viewing_direction
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



95
96
97
# File 'lib/sdr_client/deposit/request.rb', line 95

def type
  @type
end

Instance Method Details

#as_jsonObject

rubocop:enable Metrics/ParameterLists rubocop:enable Metrics/AbcSize



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/sdr_client/deposit/request.rb', line 52

def as_json
  {
    access: access_struct,
    type: type,
    administrative: administrative,
    identification: identification,
    structural: structural,
    version: 1,
    label: label.nil? ? ':auto' : label
  }
end

#for(filename) ⇒ Hash

Returns the metadata for the file.

Parameters:

  • filename (String)

Returns:

  • (Hash)

    the metadata for the file



88
89
90
91
92
93
# File 'lib/sdr_client/deposit/request.rb', line 88

def for(filename)
   = .fetch(filename, {}).with_indifferent_access
  [:access] = access unless .key?(:access)
  [:download] = download unless .key?(:download)
  
end

#with_file_sets(file_sets) ⇒ Request

rubocop:disable Metrics/AbcSize

Returns:

  • (Request)

    a clone of this request with the file_sets added



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/sdr_client/deposit/request.rb', line 66

def with_file_sets(file_sets)
  Request.new(label: label,
              access: access,
              download: download,
              apo: apo,
              collection: collection,
              copyright: copyright,
              source_id: source_id,
              catkey: catkey,
              embargo_release_date: embargo_release_date,
              embargo_access: embargo_access,
              embargo_download: embargo_download,
              type: type,
              use_statement: use_statement,
              viewing_direction: viewing_direction,
              file_sets: file_sets,
              files_metadata: )
end