Module: Zenodo::DSL::Depositions

Included in:
Zenodo::DSL
Defined in:
lib/zenodo/dsl/depositions.rb

Instance Method Summary collapse

Instance Method Details

#create_deposition(deposition:) ⇒ Zenodo::Resources::deposition?

POST /Deposit/Depositions Creates a deposition.

Parameters:

  • deposition (Hash)

    The deposition to create.

Returns:

  • (Zenodo::Resources::deposition, nil)

    .

Raises:

  • (ArgumentError)

    If the method arguments are blank.



27
28
29
30
# File 'lib/zenodo/dsl/depositions.rb', line 27

def create_deposition(deposition:)
  raise ArgumentError, "Deposition cannot be blank" if deposition.blank?
  Resources::Deposition.parse(request(:post, "deposit/depositions/", deposition))
end

#delete_deposition(id:) ⇒ Faraday::Response

DELETE /Deposit/Depositions/id Deletes a deposition.

Parameters:

  • id (String, Fixnum)

    A deposition’s ID.

Returns:

  • (Faraday::Response)

    .

Raises:

  • (ArgumentError)

    If the method arguments are blank.



49
50
51
52
# File 'lib/zenodo/dsl/depositions.rb', line 49

def delete_deposition(id:)
  raise ArgumentError, "ID cannot be blank" if id.blank?
  request(:delete, "deposit/depositions/#{id}")
end

#get_deposition(id:) ⇒ Zenodo::Resources::deposition?

GET /Deposit/Deposition/id Get a deposition.

Parameters:

  • id (String, Fixnum)

    A deposition’s ID.

Returns:

  • (Zenodo::Resources::deposition, nil)

    .

Raises:

  • (ArgumentError)

    If the method arguments are blank.



17
18
19
20
# File 'lib/zenodo/dsl/depositions.rb', line 17

def get_deposition(id:)
  raise ArgumentError, "ID cannot be blank" if id.blank?
  Resources::Deposition.parse(request(:get, "deposit/depositions/#{id}"))
end

#get_depositionsArray?

GET /Deposit/Depositions Get depositions.

Returns:

  • (Array, nil)

    .



8
9
10
# File 'lib/zenodo/dsl/depositions.rb', line 8

def get_depositions
  Resources::Deposition.parse(request(:get, "deposit/depositions/", nil, nil))
end

#update_deposition(id:, deposition:) ⇒ Zenodo::Resources::deposition?

PUT /Deposit/Depositions Updates a deposition.

Parameters:

  • id (String, Fixnum)

    A deposition’s ID.

  • deposition (Hash)

    The deposition to update.

Returns:

  • (Zenodo::Resources::deposition, nil)

    .

Raises:

  • (ArgumentError)

    If the method arguments are blank.



38
39
40
41
42
# File 'lib/zenodo/dsl/depositions.rb', line 38

def update_deposition(id:, deposition:)
  raise ArgumentError, "ID cannot be blank" if id.blank?
  raise ArgumentError, "Deposition cannot be blank" if deposition.blank?
  Resources::Deposition.parse(request(:put, "deposit/depositions/#{id}", deposition))
end