Class: Spaceship::ConnectAPI::AppReviewAttachment

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
spaceship/lib/spaceship/connect_api/models/app_review_attachment.rb

Instance Attribute Summary collapse

Attributes included from Model

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#attr_mapping, included, #initialize, #to_json, #update_attributes

Instance Attribute Details

#asset_delivery_stateObject

Returns the value of attribute asset_delivery_state.



13
14
15
# File 'spaceship/lib/spaceship/connect_api/models/app_review_attachment.rb', line 13

def asset_delivery_state
  @asset_delivery_state
end

#file_nameObject

Returns the value of attribute file_name.



10
11
12
# File 'spaceship/lib/spaceship/connect_api/models/app_review_attachment.rb', line 10

def file_name
  @file_name
end

#source_file_checksumObject

Returns the value of attribute source_file_checksum.



11
12
13
# File 'spaceship/lib/spaceship/connect_api/models/app_review_attachment.rb', line 11

def source_file_checksum
  @source_file_checksum
end

#upload_operationsObject

Returns the value of attribute upload_operations.



12
13
14
# File 'spaceship/lib/spaceship/connect_api/models/app_review_attachment.rb', line 12

def upload_operations
  @upload_operations
end

#uploadedObject

Returns the value of attribute uploaded.



14
15
16
# File 'spaceship/lib/spaceship/connect_api/models/app_review_attachment.rb', line 14

def uploaded
  @uploaded
end

Class Method Details

.create(app_store_review_detail_id: nil, path: nil) ⇒ Object

API



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'spaceship/lib/spaceship/connect_api/models/app_review_attachment.rb', line 32

def self.create(app_store_review_detail_id: nil, path: nil)
  require 'faraday'

  filename = File.basename(path)
  filesize = File.size(path)
  bytes = File.binread(path)

  post_attributes = {
    fileSize: filesize,
    fileName: filename
  }

  # Create placeholder
  attachment = Spaceship::ConnectAPI.post_app_review_attachment(
    app_store_review_detail_id: app_store_review_detail_id,
    attributes: post_attributes
  ).to_models.first

  # Upload the file
  upload_operations = attachment.upload_operations
  Spaceship::ConnectAPI::FileUploader.upload(upload_operations, bytes)

  # Update file uploading complete
  patch_attributes = {
    uploaded: true,
    sourceFileChecksum: Digest::MD5.hexdigest(bytes)
  }

  Spaceship::ConnectAPI.patch_app_review_attachment(
    app_review_attachment_id: attachment.id,
    attributes: patch_attributes
  ).to_models.first
end

.typeObject



24
25
26
# File 'spaceship/lib/spaceship/connect_api/models/app_review_attachment.rb', line 24

def self.type
  return "appReviewAttachments"
end

Instance Method Details

#delete!(filter: {}, includes: nil, limit: nil, sort: nil) ⇒ Object



66
67
68
# File 'spaceship/lib/spaceship/connect_api/models/app_review_attachment.rb', line 66

def delete!(filter: {}, includes: nil, limit: nil, sort: nil)
  Spaceship::ConnectAPI.delete_app_review_attachment(app_review_attachment_id: id)
end