Class: Spaceship::ConnectAPI::AppStoreReviewAttachment

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

Instance Attribute Summary collapse

Attributes included from Model

#id, #reverse_attr_map

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#attr_mapping, included, #initialize, #reverse_attr_mapping, #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_store_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_store_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_store_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_store_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_store_review_attachment.rb', line 14

def uploaded
  @uploaded
end

Class Method Details

.create(client: nil, 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
65
# File 'spaceship/lib/spaceship/connect_api/models/app_store_review_attachment.rb', line 32

def self.create(client: nil, app_store_review_detail_id: nil, path: nil)
  client ||= Spaceship::ConnectAPI
  require 'faraday'

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

  post_attributes = {
    fileSize: filesize,
    fileName: filename
  }

  # Create placeholder
  attachment = client.post_app_store_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)
  }

  client.patch_app_store_review_attachment(
    app_store_review_attachment_id: attachment.id,
    attributes: patch_attributes
  ).to_models.first
end

.typeObject



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

def self.type
  return "appStoreReviewAttachments"
end

Instance Method Details

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



67
68
69
70
# File 'spaceship/lib/spaceship/connect_api/models/app_store_review_attachment.rb', line 67

def delete!(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)
  client ||= Spaceship::ConnectAPI
  client.delete_app_store_review_attachment(app_store_review_attachment_id: id)
end