|
| 1 | +#frozen_string_literal: true |
| 2 | + |
| 3 | +module Appwrite |
| 4 | + module Models |
| 5 | + class TemplateFunction |
| 6 | + attr_reader :icon |
| 7 | + attr_reader :id |
| 8 | + attr_reader :name |
| 9 | + attr_reader :tagline |
| 10 | + attr_reader :permissions |
| 11 | + attr_reader :events |
| 12 | + attr_reader :cron |
| 13 | + attr_reader :timeout |
| 14 | + attr_reader :use_cases |
| 15 | + attr_reader :runtimes |
| 16 | + attr_reader :instructions |
| 17 | + attr_reader :vcs_provider |
| 18 | + attr_reader :provider_repository_id |
| 19 | + attr_reader :provider_owner |
| 20 | + attr_reader :provider_version |
| 21 | + attr_reader :variables |
| 22 | + attr_reader :scopes |
| 23 | + |
| 24 | + def initialize( |
| 25 | + icon:, |
| 26 | + id:, |
| 27 | + name:, |
| 28 | + tagline:, |
| 29 | + permissions:, |
| 30 | + events:, |
| 31 | + cron:, |
| 32 | + timeout:, |
| 33 | + use_cases:, |
| 34 | + runtimes:, |
| 35 | + instructions:, |
| 36 | + vcs_provider:, |
| 37 | + provider_repository_id:, |
| 38 | + provider_owner:, |
| 39 | + provider_version:, |
| 40 | + variables:, |
| 41 | + scopes: |
| 42 | + ) |
| 43 | + @icon = icon |
| 44 | + @id = id |
| 45 | + @name = name |
| 46 | + @tagline = tagline |
| 47 | + @permissions = permissions |
| 48 | + @events = events |
| 49 | + @cron = cron |
| 50 | + @timeout = timeout |
| 51 | + @use_cases = use_cases |
| 52 | + @runtimes = runtimes |
| 53 | + @instructions = instructions |
| 54 | + @vcs_provider = vcs_provider |
| 55 | + @provider_repository_id = provider_repository_id |
| 56 | + @provider_owner = provider_owner |
| 57 | + @provider_version = provider_version |
| 58 | + @variables = variables |
| 59 | + @scopes = scopes |
| 60 | + end |
| 61 | + |
| 62 | + def self.from(map:) |
| 63 | + TemplateFunction.new( |
| 64 | + icon: map["icon"], |
| 65 | + id: map["id"], |
| 66 | + name: map["name"], |
| 67 | + tagline: map["tagline"], |
| 68 | + permissions: map["permissions"], |
| 69 | + events: map["events"], |
| 70 | + cron: map["cron"], |
| 71 | + timeout: map["timeout"], |
| 72 | + use_cases: map["useCases"], |
| 73 | + runtimes: map["runtimes"].map { |it| TemplateRuntime.from(map: it) }, |
| 74 | + instructions: map["instructions"], |
| 75 | + vcs_provider: map["vcsProvider"], |
| 76 | + provider_repository_id: map["providerRepositoryId"], |
| 77 | + provider_owner: map["providerOwner"], |
| 78 | + provider_version: map["providerVersion"], |
| 79 | + variables: map["variables"].map { |it| TemplateVariable.from(map: it) }, |
| 80 | + scopes: map["scopes"] |
| 81 | + ) |
| 82 | + end |
| 83 | + |
| 84 | + def to_map |
| 85 | + { |
| 86 | + "icon": @icon, |
| 87 | + "id": @id, |
| 88 | + "name": @name, |
| 89 | + "tagline": @tagline, |
| 90 | + "permissions": @permissions, |
| 91 | + "events": @events, |
| 92 | + "cron": @cron, |
| 93 | + "timeout": @timeout, |
| 94 | + "useCases": @use_cases, |
| 95 | + "runtimes": @runtimes.map { |it| it.to_map }, |
| 96 | + "instructions": @instructions, |
| 97 | + "vcsProvider": @vcs_provider, |
| 98 | + "providerRepositoryId": @provider_repository_id, |
| 99 | + "providerOwner": @provider_owner, |
| 100 | + "providerVersion": @provider_version, |
| 101 | + "variables": @variables.map { |it| it.to_map }, |
| 102 | + "scopes": @scopes |
| 103 | + } |
| 104 | + end |
| 105 | + end |
| 106 | + end |
| 107 | +end |
0 commit comments