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



122
123
124
125
126
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 122

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



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

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



106
107
108
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 106

def self.type
  return "appScreenshotSets"
end

Instance Method Details

#apple_tv?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 110

def apple_tv?
  DisplayType::APP_APPLE_TV == screenshot_display_type
end

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



133
134
135
136
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 133

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)


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

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

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



161
162
163
164
165
166
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 161

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



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb', line 138

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