register_subscriber for soracom-sdk-ruby cannot run

Asked 1 months ago, Updated 1 months ago, 3 views

I tried to register the soracom SIM I bought from Amazon with the API, but it didn't work.
An ArgumentError occurs when you run the register_subscriber of soracom-sdk-ruby.

#<ArgumentError: wrong number of arguments (given2, expected 0)>

We created a class similar to the following and tested it by calling the SDK register_subscriber method in register_sim.

class SimDevice
  def client
    @soracom||=Soracom::Client.new(
      auth_key_id —SORACOM_AUTH_KEY_ID,
      auth_key —SORACOM_AUTH_KEY_SECRET
    )
  end

  def register_sim
    imsi='XXXXXXXXXXXXXXX'
    registration_secret='XXXX'#PASSCODE??
    client.register_subscriber(imsi,registration_secret)#Error
  end
end

I have two questions.
1. Is the registrationSecret written in the API document correct for PASSCODE written on the SIM card?

2. If 1 is correct, how can I use the register_subscriber method?

If anyone knows, please take care of me.

(Reference)
·soracom-sdk-ruby
https://github.com/soracom/soracom-sdk-ruby

·API documentation
https://dev.soracom.io/jp/docs/api/

ruby soracom

2022-09-30 12:06

1 Answers

The method is defined using keyword arguments, so when calling a method, the variable name must be specified as follows:

client.register_subscriber(imsi:imsi,registration_secret:registration_secret)

https://github.com/soracom/soracom-sdk-ruby/blob/master/lib/soracom/client.rb#L81

For your information, we have made a little effort to make the sample code provided work independently.

require'soracom'
class SimDevice
  def client
    @soracom||=Soracom::Client.new(
      auth_key_id —SORACOM_AUTH_KEY_ID,
      auth_key —SORACOM_AUTH_KEY_SECRET
    )
  end

  def register_sim
    imsi='XXXXXXXXXXXXXXX'
    registration_secret='XXXXX'
    client.register_subscriber(imsi:imsi, registration_secret:registration_secret)or
  end
end

p SimDevice.new().register_sim#=>{"code"=>"SEM0001", "message"=>"No such resource found"}

It should work if you give me the correct IMSI and passcode.


2022-09-30 12:06

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.