Class: Spaceship::ConnectAPI::AppScreenshotSet

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

Defined Under Namespace

Modules: DisplayType

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

#app_screenshotsObject

Returns the value of attribute app_screenshots.



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

def app_screenshots
  @app_screenshots
end

#screenshot_display_typeObject

Returns the value of attribute screenshot_display_type.



9
10
11
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 9

def screenshot_display_type
  @screenshot_display_type
end

Class Method Details

.all(client: nil, app_store_version_localization_id: nil, filter: {}, includes: nil, limit: nil, sort: nil) ⇒ Object

API



129
130
131
132
133
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 129

def self.all(client: nil, app_store_version_localization_id: nil, filter: {}, includes: nil, limit: nil, sort: nil)
  client ||= Spaceship::ConnectAPI
  resp = client.get_app_screenshot_sets(app_store_version_localization_id: app_store_version_localization_id, filter: filter, includes: includes, limit: limit, sort: sort)
  return resp.to_models
end

.get(client: nil, app_screenshot_set_id: nil, includes: "appScreenshots") ⇒ Object



135
136
137
138
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 135

def self.get(client: nil, app_screenshot_set_id: nil, includes: "appScreenshots")
  client ||= Spaceship::ConnectAPI
  return client.get_app_screenshot_set(app_screenshot_set_id: app_screenshot_set_id, filter: nil, includes: includes, limit: nil, sort: nil).first
end

.typeObject



113
114
115
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 113

def self.type
  return "appScreenshotSets"
end

Instance Method Details

#apple_tv?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 117

def apple_tv?
  DisplayType::APP_APPLE_TV == screenshot_display_type
end

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



140
141
142
143
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 140

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

#imessage?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 121

def imessage?
  DisplayType::ALL_IMESSAGE.include?(screenshot_display_type)
end

#reorder_screenshots(client: nil, app_screenshot_ids: nil) ⇒ Object



168
169
170
171
172
173
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 168

def reorder_screenshots(client: nil, app_screenshot_ids: nil)
  client ||= Spaceship::ConnectAPI
  client.patch_app_screenshot_set_screenshots(app_screenshot_set_id: id, app_screenshot_ids: app_screenshot_ids)

  return client.get_app_screenshot_set(app_screenshot_set_id: id, includes: "appScreenshots").first
end

#upload_screenshot(client: nil, path: nil, wait_for_processing: true, position: nil) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 145

def upload_screenshot(client: nil, path: nil, wait_for_processing: true, position: nil)
  client ||= Spaceship::ConnectAPI
  screenshot = Spaceship::ConnectAPI::AppScreenshot.create(client: client, app_screenshot_set_id: id, path: path, wait_for_processing: wait_for_processing)

  # Reposition (if specified)
  unless position.nil?
    # Get all app preview ids
    set = AppScreenshotSet.get(client: client, app_screenshot_set_id: id)
    app_screenshot_ids = set.app_screenshots.map(&:id)

    # Remove new uploaded screenshot
    app_screenshot_ids.delete(screenshot.id)

    # Insert screenshot at specified position
    app_screenshot_ids = app_screenshot_ids.insert(position, screenshot.id).compact

    # Reorder screenshots
    reorder_screenshots(client: client, app_screenshot_ids: app_screenshot_ids)
  end

  return screenshot
end