Module: EverSdk::Client

Defined in:
lib/ever_sdk_client/client.rb

Defined Under Namespace

Modules: ErrorCode Classes: AppRequestResult

Constant Summary collapse

ResultOfVersion =
KwStruct.new(:version)
ResultOfGetApiReference =
KwStruct.new(:api)
BuildInfoDependency =
KwStruct.new(:name, :git_commit) do
  def self.from_json(j)
    return nil if j.nil?

    self.new(name: j["name"], git_commit: j["git_commit"])
  end
end
ResultOfBuildInfo =
KwStruct.new(:build_number, :dependencies)
ParamsOfAppRequest =
KwStruct.new(:app_request_id, :request_data)
ParamsOfResolveAppRequest =
KwStruct.new(:app_request_id, :result) do
  def to_h
    {
      app_request_id: app_request_id,
      result: result.to_h
    }
  end
end

Class Method Summary collapse

Class Method Details

.build_info(ctx) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/ever_sdk_client/client.rb', line 152

def self.build_info(ctx)
  Interop::request_to_native_lib(ctx, "client.build_info") do |resp|
    if resp.success?
      dp_s = resp.result["dependencies"].map { |x| BuildInfoDependency.from_json(x) }
      yield NativeLibResponseResult.new(
        result: ResultOfBuildInfo.new(
          build_number: resp.result["build_number"],
          dependencies: dp_s
        )
      )
    else
      yield resp
    end
  end
end

.config(ctx) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/ever_sdk_client/client.rb', line 123

def self.config(ctx)
  Interop::request_to_native_lib(ctx, "client.config") do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ClientConfig.new(
          network: resp.result["network"],
          crypto: resp.result["crypto"],
          abi: resp.result["abi"],
          boc: resp.result["boc"]
        )
      )
    else
      yield resp
    end
  end
end

.get_api_reference(ctx) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
# File 'lib/ever_sdk_client/client.rb', line 140

def self.get_api_reference(ctx)
  Interop::request_to_native_lib(ctx, "client.get_api_reference") do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ResultOfGetApiReference.new(api: resp.result["api"])
      )
    else
      yield resp
    end
  end
end

.resolve_app_request(ctx, params) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
# File 'lib/ever_sdk_client/client.rb', line 168

def self.resolve_app_request(ctx, params)
  Interop::request_to_native_lib(ctx, "client.resolve_app_request", params) do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ""
      )
    else
      yield resp
    end
  end
end

.version(ctx) ⇒ Object

params:

ctx

ClientContext object



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/ever_sdk_client/client.rb', line 111

def self.version(ctx)
  Interop::request_to_native_lib(ctx, "client.version") do |resp|
    if resp.success?
      yield NativeLibResponseResult.new(
        result: ResultOfVersion.new(version: resp.result["version"])
      )
    else
      yield resp
    end
  end
end