omisego 0.9.6 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/README.md +254 -149
- data/lib/omisego/account.rb +6 -0
- data/lib/omisego/balance.rb +3 -33
- data/lib/omisego/configuration.rb +5 -4
- data/lib/omisego/request.rb +1 -3
- data/lib/omisego/setting.rb +5 -5
- data/lib/omisego/{minted_token.rb → token.rb} +1 -1
- data/lib/omisego/transaction.rb +12 -1
- data/lib/omisego/transaction_source.rb +1 -1
- data/lib/omisego/user.rb +26 -14
- data/lib/omisego/version.rb +1 -1
- data/lib/omisego/wallet.rb +57 -0
- data/lib/omisego.rb +3 -2
- metadata +5 -4
- data/lib/omisego/address.rb +0 -11
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f1a8f2706d997f2bedf1d424565799029ff5a7cb
         | 
| 4 | 
            +
              data.tar.gz: cd5579d16565076cf5929027756db4a11f1b6e91
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2063f7387e607e1dc751d9eafcfd87e9962f53d8541fe26df10cf85024bae73b2701056e8d3b029a798daba650f06ab581669d6b139a81ff7dcf59e6d59887cf
         | 
| 7 | 
            +
              data.tar.gz: 6f0d58c04c6685ae62ed47ad76310ade7ec861e21d70d6173b71e5b823b767d64a5d3e9c29bfa47e9ee209908926e08743b1971e79f11a4bbbcde80befacc794
         | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,12 +1,18 @@ | |
| 1 | 
            +
             | 
| 2 | 
            +
            [](https://travis-ci.org/omisego/ruby-sdk)
         | 
| 3 | 
            +
            [](https://badge.fury.io/rb/omisego)
         | 
| 4 | 
            +
             | 
| 1 5 | 
             
            # OmiseGO
         | 
| 2 6 |  | 
| 3 7 | 
             
            OmiseGO is a Ruby SDK meant to communicate with an OmiseGO eWallet setup.
         | 
| 4 8 |  | 
| 9 | 
            +
            For more details about the web API being wrapped by this SDK, take a look at the [OpenAPI Specification](https://ewallet.demo.omisego.io/api/docs.ui). You are free to use that web API directly if you prefer, this SDK is only provided as a convenient way to make those HTTP calls and return Ruby objects as responses.
         | 
| 10 | 
            +
             | 
| 5 11 | 
             
            ## Installation
         | 
| 6 12 |  | 
| 7 13 | 
             
            Add this line to your application's Gemfile:
         | 
| 8 14 |  | 
| 9 | 
            -
            ```
         | 
| 15 | 
            +
            ```ruby
         | 
| 10 16 | 
             
            gem 'omisego'
         | 
| 11 17 | 
             
            ```
         | 
| 12 18 |  | 
| @@ -26,7 +32,7 @@ In the end, the choice is yours and the optimal solution depends on your needs. | |
| 26 32 |  | 
| 27 33 | 
             
            ### Global init
         | 
| 28 34 |  | 
| 29 | 
            -
            ```
         | 
| 35 | 
            +
            ```ruby
         | 
| 30 36 | 
             
            # config/initializers/omisego.rb
         | 
| 31 37 | 
             
            OmiseGO.configure do |config|
         | 
| 32 38 | 
             
              config.access_key = ENV['OMISEGO_ACCESS_KEY']
         | 
| @@ -37,15 +43,29 @@ end | |
| 37 43 |  | 
| 38 44 | 
             
            If initialized this way, the `OmiseGO` classes can be used without specifying the client.
         | 
| 39 45 |  | 
| 46 | 
            +
            ```ruby
         | 
| 47 | 
            +
            user = OmiseGO::User.find(provider_user_id: 'provider_user_id01')
         | 
| 40 48 | 
             
            ```
         | 
| 41 | 
            -
             | 
| 49 | 
            +
             | 
| 50 | 
            +
            ### Client init
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            With this approach, the client needs to be passed in every call and will be used as the call initiator.
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            ```ruby
         | 
| 55 | 
            +
            client = OmiseGO::Client.new(
         | 
| 56 | 
            +
              access_key: ENV['OMISEGO_ACCESS_KEY'],
         | 
| 57 | 
            +
              secret_key: ENV['OMISEGO_SECRET_KEY'],
         | 
| 58 | 
            +
              base_url:   ENV['OMISEGO_BASE_URL']
         | 
| 59 | 
            +
            )
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            user = OmiseGO::User.find(provider_user_id: 'provider_user_id01', client: client)
         | 
| 42 62 | 
             
            ```
         | 
| 43 63 |  | 
| 44 | 
            -
            ### Logging
         | 
| 64 | 
            +
            ### Logging Configuration
         | 
| 45 65 |  | 
| 46 66 | 
             
            The Ruby SDK comes with the possibility to log requests to the eWallet. For example, within a Rails application, the following can be defined:
         | 
| 47 67 |  | 
| 48 | 
            -
            ```
         | 
| 68 | 
            +
            ```ruby
         | 
| 49 69 | 
             
            # config/initializers/omisego.rb
         | 
| 50 70 | 
             
            OmiseGO.configure do |config|
         | 
| 51 71 | 
             
              config.access_key = ENV['OMISEGO_ACCESS_KEY']
         | 
| @@ -77,35 +97,44 @@ Cache-Control: max-age=0, private, must-revalidate | |
| 77 97 | 
             
            {"version":"1","success":true,"data":{"object":"authentication_token","authentication_token":[FILTERED]}}
         | 
| 78 98 | 
             
            ```
         | 
| 79 99 |  | 
| 80 | 
            -
             | 
| 100 | 
            +
            ## Usage
         | 
| 81 101 |  | 
| 82 | 
            -
             | 
| 102 | 
            +
            All the calls below will communicate with the OmiseGO wallet specified in the `base_url` configuration. They will either return an instance of `OmiseGO:Error` or of the appropriate model (`User`, `Balance`, etc.), see [the list of models](#models) for more information.
         | 
| 83 103 |  | 
| 84 | 
            -
             | 
| 85 | 
            -
            client = OmiseGO::Client.new(
         | 
| 86 | 
            -
              access_key: ENV['OMISEGO_ACCESS_KEY'],
         | 
| 87 | 
            -
              secret_key: ENV['OMISEGO_SECRET_KEY'],
         | 
| 88 | 
            -
              base_url:   ENV['OMISEGO_BASE_URL']
         | 
| 89 | 
            -
            )
         | 
| 104 | 
            +
            __The method `#error?` can be used on any model to check if it's an error or a valid result.__
         | 
| 90 105 |  | 
| 91 | 
            -
            user = OmiseGO::User.find(provider_user_id: 'some_uuid', client: client)
         | 
| 92 | 
            -
            ```
         | 
| 93 106 |  | 
| 94 | 
            -
             | 
| 107 | 
            +
            ### Understanding Idempotency
         | 
| 95 108 |  | 
| 96 | 
            -
             | 
| 109 | 
            +
            Some of the calls in the web API (and in the methods below) contain a parameter called `idempotency_token`.
         | 
| 97 110 |  | 
| 98 | 
            -
             | 
| 111 | 
            +
            ### Understanding wallet types
         | 
| 112 | 
            +
             | 
| 113 | 
            +
            ### Understanding Metadata and Encrypted Metadata
         | 
| 114 | 
            +
             | 
| 115 | 
            +
             | 
| 116 | 
            +
            ### All available methods
         | 
| 117 | 
            +
             | 
| 118 | 
            +
            - [Find a user](#find-user)
         | 
| 119 | 
            +
            - [Create a user](#create-user)
         | 
| 120 | 
            +
            - [Update a user](#update-user)
         | 
| 121 | 
            +
            - [Get all wallets for a user](#get-all-wallets-for-a-user)
         | 
| 122 | 
            +
            - [Loggging in a user](#login-user)
         | 
| 123 | 
            +
            - [Get all wallets](#all-wallets)
         | 
| 124 | 
            +
            - [Credit a user's wallet](#credit-wallet)
         | 
| 125 | 
            +
            - [Debit a user's wallet](#debit-wallet)
         | 
| 99 126 |  | 
| 100 127 | 
             
            ### Managing Users
         | 
| 101 128 |  | 
| 102 | 
            -
            #### Find
         | 
| 129 | 
            +
            #### Find User
         | 
| 103 130 |  | 
| 104 131 | 
             
            Retrieve a user from the eWallet API.
         | 
| 105 132 |  | 
| 106 | 
            -
            ```
         | 
| 133 | 
            +
            ```ruby
         | 
| 107 134 | 
             
            user = OmiseGO::User.find(
         | 
| 108 | 
            -
              provider_user_id: ' | 
| 135 | 
            +
              provider_user_id: 'provider_user_id01',
         | 
| 136 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 137 | 
            +
                          # defined in config
         | 
| 109 138 | 
             
            )
         | 
| 110 139 | 
             
            ```
         | 
| 111 140 |  | 
| @@ -113,18 +142,21 @@ Returns either: | |
| 113 142 | 
             
            - An `OmiseGO::User` instance
         | 
| 114 143 | 
             
            - An `OmiseGO::Error` instance
         | 
| 115 144 |  | 
| 116 | 
            -
            #### Create
         | 
| 145 | 
            +
            #### Create User
         | 
| 117 146 |  | 
| 118 147 | 
             
            Create a user in the eWallet API database. The `provider_user_id` is how a user is identified and cannot be changed later on.
         | 
| 119 148 |  | 
| 120 | 
            -
            ```
         | 
| 149 | 
            +
            ```ruby
         | 
| 121 150 | 
             
            user = OmiseGO::User.create(
         | 
| 122 | 
            -
              provider_user_id: ' | 
| 151 | 
            +
              provider_user_id: 'provider_user_id01',
         | 
| 123 152 | 
             
              username: 'john@doe.com',
         | 
| 124 153 | 
             
              metadata: {
         | 
| 125 154 | 
             
                first_name: 'John',
         | 
| 126 155 | 
             
                last_name: 'Doe'
         | 
| 127 | 
            -
              }
         | 
| 156 | 
            +
              },                      # optional, defaults to {}
         | 
| 157 | 
            +
              encrypted_metadata: {}, # optional, defaults to {}
         | 
| 158 | 
            +
              client: nil             # optional, defauls to nil and uses the client
         | 
| 159 | 
            +
                                      # defined in config
         | 
| 128 160 | 
             
            )
         | 
| 129 161 | 
             
            ```
         | 
| 130 162 |  | 
| @@ -132,18 +164,29 @@ Returns either: | |
| 132 164 | 
             
            - An `OmiseGO::User` instance
         | 
| 133 165 | 
             
            - An `OmiseGO::Error` instance
         | 
| 134 166 |  | 
| 135 | 
            -
            #### Update
         | 
| 167 | 
            +
            #### Update User
         | 
| 136 168 |  | 
| 137 169 | 
             
            Update a user in the eWallet API database. All fields need to be provided and the values in the eWallet database will be replaced with the sent ones (behaves like a HTTP `PUT`). Sending `metadata: {}` in the request below would remove the `first_name` and `last_name` fields for example.
         | 
| 138 170 |  | 
| 139 | 
            -
            ```
         | 
| 171 | 
            +
            ```ruby
         | 
| 140 172 | 
             
            user = OmiseGO::User.update(
         | 
| 141 | 
            -
              provider_user_id: ' | 
| 173 | 
            +
              provider_user_id: 'provider_user_id01',
         | 
| 142 174 | 
             
              username: 'jane@doe.com',
         | 
| 143 | 
            -
              metadata: {
         | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
             | 
| 175 | 
            +
              metadata: {},           # optional, defaults to {}
         | 
| 176 | 
            +
              encrypted_metadata: {}, # optional, defaults to {}
         | 
| 177 | 
            +
              client: nil             # optional, defauls to nil and uses the client
         | 
| 178 | 
            +
                                      # defined in config
         | 
| 179 | 
            +
            )
         | 
| 180 | 
            +
             | 
| 181 | 
            +
            # or
         | 
| 182 | 
            +
             | 
| 183 | 
            +
            user = OmiseGO::User.find(provider_user_id: 'provider_user_id01')
         | 
| 184 | 
            +
            user = user.update(
         | 
| 185 | 
            +
              username: 'jane@doe.com',
         | 
| 186 | 
            +
              metadata: {},           # optional, defaults to {}
         | 
| 187 | 
            +
              encrypted_metadata: {}, # optional, defaults to {}
         | 
| 188 | 
            +
              client: nil             # optional, defauls to nil and uses the client
         | 
| 189 | 
            +
                                      # defined in config
         | 
| 147 190 | 
             
            )
         | 
| 148 191 | 
             
            ```
         | 
| 149 192 |  | 
| @@ -151,125 +194,128 @@ Returns either: | |
| 151 194 | 
             
            - An `OmiseGO::User` instance
         | 
| 152 195 | 
             
            - An `OmiseGO::Error` instance
         | 
| 153 196 |  | 
| 154 | 
            -
             | 
| 197 | 
            +
            #### Get all wallets for a user
         | 
| 155 198 |  | 
| 156 | 
            -
             | 
| 199 | 
            +
            Retrieve a list of wallets (with only one primary wallet for now) containing a list of balances.
         | 
| 157 200 |  | 
| 158 | 
            -
             | 
| 201 | 
            +
            ```ruby
         | 
| 202 | 
            +
            wallets = OmiseGO::User.wallets(
         | 
| 203 | 
            +
              provider_user_id: 'provider_user_id01',
         | 
| 204 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 205 | 
            +
                          # defined in config
         | 
| 206 | 
            +
            )
         | 
| 159 207 |  | 
| 160 | 
            -
             | 
| 161 | 
            -
             | 
| 162 | 
            -
             | 
| 208 | 
            +
            # or
         | 
| 209 | 
            +
             | 
| 210 | 
            +
            user = OmiseGO::User.find(provider_user_id: 'provider_user_id01')
         | 
| 211 | 
            +
            wallets = user.wallets(
         | 
| 212 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 213 | 
            +
                          # defined in config
         | 
| 163 214 | 
             
            )
         | 
| 164 215 | 
             
            ```
         | 
| 165 216 |  | 
| 166 217 | 
             
            Returns either:
         | 
| 167 | 
            -
            - An `OmiseGO:: | 
| 218 | 
            +
            - An `OmiseGO::List` of `OmiseGO::Wallet` instances
         | 
| 168 219 | 
             
            - An `OmiseGO::Error` instance
         | 
| 169 220 |  | 
| 170 | 
            -
            ### Managing  | 
| 221 | 
            +
            ### Managing Sessions
         | 
| 171 222 |  | 
| 172 | 
            -
             | 
| 173 | 
            -
            - [Credit](#Credit)
         | 
| 174 | 
            -
            - [Debit](#Debit)
         | 
| 223 | 
            +
            #### Login User
         | 
| 175 224 |  | 
| 176 | 
            -
             | 
| 225 | 
            +
            Login a user and retrieve an `authentication_token` that can be passed to a mobile client to make calls to the eWallet API directly.
         | 
| 177 226 |  | 
| 178 | 
            -
             | 
| 227 | 
            +
            ```ruby
         | 
| 228 | 
            +
            auth_token = OmiseGO::User.login(
         | 
| 229 | 
            +
              provider_user_id: 'provider_user_id01',
         | 
| 230 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 231 | 
            +
                          # defined in config
         | 
| 232 | 
            +
            )
         | 
| 179 233 |  | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 234 | 
            +
            # or
         | 
| 235 | 
            +
             | 
| 236 | 
            +
            user = OmiseGO::User.find(provider_user_id: 'provider_user_id01')
         | 
| 237 | 
            +
            auth_token = user.login(
         | 
| 238 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 239 | 
            +
                          # defined in config
         | 
| 183 240 | 
             
            )
         | 
| 184 241 | 
             
            ```
         | 
| 185 242 |  | 
| 186 243 | 
             
            Returns either:
         | 
| 187 | 
            -
            - An `OmiseGO:: | 
| 244 | 
            +
            - An `OmiseGO::AuthenticationToken` instance
         | 
| 188 245 | 
             
            - An `OmiseGO::Error` instance
         | 
| 189 246 |  | 
| 190 | 
            -
             | 
| 247 | 
            +
            ### Managing Wallets
         | 
| 191 248 |  | 
| 192 | 
            -
             | 
| 249 | 
            +
            #### All Wallets
         | 
| 193 250 |  | 
| 194 | 
            -
             | 
| 195 | 
            -
             | 
| 196 | 
            -
             | 
| 197 | 
            -
             | 
| 198 | 
            -
               | 
| 199 | 
            -
               | 
| 200 | 
            -
             | 
| 251 | 
            +
            Retrieve a list of wallets (with only one address for now) containing a list of balances.
         | 
| 252 | 
            +
             | 
| 253 | 
            +
            ```ruby
         | 
| 254 | 
            +
            wallets = OmiseGO::Wallet.all(
         | 
| 255 | 
            +
              provider_user_id: 'provider_user_id01',
         | 
| 256 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 257 | 
            +
                          # defined in config
         | 
| 201 258 | 
             
            )
         | 
| 202 259 | 
             
            ```
         | 
| 203 260 |  | 
| 204 | 
            -
             | 
| 261 | 
            +
            Returns either:
         | 
| 262 | 
            +
            - An `OmiseGO::List` of `OmiseGO::Wallet` instances
         | 
| 263 | 
            +
            - An `OmiseGO::Error` instance
         | 
| 205 264 |  | 
| 206 | 
            -
             | 
| 207 | 
            -
            address = OmiseGO::Balance.credit(
         | 
| 208 | 
            -
              account_id: 'account_uuid',
         | 
| 209 | 
            -
              provider_user_id: 'some_uuid',
         | 
| 210 | 
            -
              token_id: 'OMG:5e9c0be5-15d1-4463-9ec2-02bc8ded7120',
         | 
| 211 | 
            -
              amount: 10_000,
         | 
| 212 | 
            -
              idempotency_token: "123",
         | 
| 213 | 
            -
              metadata: {}
         | 
| 214 | 
            -
            )
         | 
| 215 | 
            -
            ```
         | 
| 265 | 
            +
            #### Credit Wallet
         | 
| 216 266 |  | 
| 217 | 
            -
             | 
| 267 | 
            +
            Transfer the specified amount (as an integer, down to the `subunit_to_unit`) from an account's wallet to a user's wallet (defaults to the user's primary wallet).
         | 
| 218 268 |  | 
| 219 | 
            -
             | 
| 269 | 
            +
            __In the following methods, an idempotency token is used to ensure that one specific credit/debit occurs only once. The implementer is responsible for ensuring that those idempotency tokens are unique - sending the same one two times will prevent the second transaction from happening__
         | 
| 220 270 |  | 
| 221 | 
            -
             | 
| 222 | 
            -
             | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 271 | 
            +
            For both the user and the account, an address can be specified to use a different wallet than the primary one.
         | 
| 272 | 
            +
             | 
| 273 | 
            +
            ```ruby
         | 
| 274 | 
            +
            wallet = OmiseGO::Wallet.credit(
         | 
| 275 | 
            +
              provider_user_id: 'provider_user_id01',
         | 
| 276 | 
            +
              user_address: nil, # optional, defaults to the user's primary wallet
         | 
| 277 | 
            +
              account_id: 'acc_01C4T2Y5SFYASXXYANV96MQQC9',
         | 
| 278 | 
            +
              account_address: nil, # optional, defaults to the account's primary wallet
         | 
| 279 | 
            +
              token_id: 'tok_OMG_01ccmny8yne44b188287d44498',
         | 
| 225 280 | 
             
              amount: 10_000,
         | 
| 226 281 | 
             
              idempotency_token: "123",
         | 
| 227 | 
            -
              metadata: {}
         | 
| 282 | 
            +
              metadata: {}, # optional, defaults to {}
         | 
| 283 | 
            +
              encrypted_metadata: {}, # optional, defaults to {}
         | 
| 284 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 285 | 
            +
                          # defined in config
         | 
| 228 286 | 
             
            )
         | 
| 229 287 | 
             
            ```
         | 
| 230 288 |  | 
| 231 | 
            -
             | 
| 289 | 
            +
            Returns either:
         | 
| 290 | 
            +
            - An `OmiseGO::List` of `OmiseGO::Wallet` instances (containing the 2 wallets involved in the transaction)
         | 
| 291 | 
            +
            - An `OmiseGO::Error` instance
         | 
| 232 292 |  | 
| 233 | 
            -
             | 
| 234 | 
            -
            address = OmiseGO::Balance.debit(
         | 
| 235 | 
            -
              account_id: 'account_uuid',
         | 
| 236 | 
            -
              provider_user_id: 'some_uuid',
         | 
| 237 | 
            -
              token_id: 'OMG:5e9c0be5-15d1-4463-9ec2-02bc8ded7120',
         | 
| 238 | 
            -
              amount: 10_000,
         | 
| 239 | 
            -
              idempotency_token: "123",
         | 
| 240 | 
            -
              metadata: {}
         | 
| 241 | 
            -
            )
         | 
| 242 | 
            -
            ```
         | 
| 293 | 
            +
            #### Debit Wallet
         | 
| 243 294 |  | 
| 244 | 
            -
             | 
| 295 | 
            +
            Transfer the specified amount (as an integer, down to the `subunit_to_unit`) from the specified user's primary wallet back to the specified account's primary wallet. If you wish to use secondary or burn wallets, they can be specified in `user_address` and `account_address`.
         | 
| 245 296 |  | 
| 246 | 
            -
            ```
         | 
| 247 | 
            -
             | 
| 248 | 
            -
               | 
| 249 | 
            -
               | 
| 250 | 
            -
               | 
| 251 | 
            -
               | 
| 297 | 
            +
            ```ruby
         | 
| 298 | 
            +
            wallet = OmiseGO::Wallet.debit(
         | 
| 299 | 
            +
              provider_user_id: 'provider_user_id01',
         | 
| 300 | 
            +
              user_address: nil, # optional, defaults to the user's primary wallet
         | 
| 301 | 
            +
              account_id: 'acc_01C4T2Y5SFYASXXYANV96MQQC9',
         | 
| 302 | 
            +
              account_address: nil, # optional, defaults to the account's primary wallet
         | 
| 303 | 
            +
              token_id: 'tok_OMG_01ccmny8yne44b188287d44498',
         | 
| 252 304 | 
             
              amount: 10_000,
         | 
| 253 305 | 
             
              idempotency_token: "123",
         | 
| 254 | 
            -
              metadata: {}
         | 
| 306 | 
            +
              metadata: {}, # optional, defaults to {}
         | 
| 307 | 
            +
              encrypted_metadata: {}, # optional, defaults to {}
         | 
| 308 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 309 | 
            +
                          # defined in config
         | 
| 255 310 | 
             
            )
         | 
| 256 311 | 
             
            ```
         | 
| 257 312 |  | 
| 258 | 
            -
             | 
| 259 | 
            -
             | 
| 260 | 
            -
            #### All
         | 
| 261 | 
            -
             | 
| 262 | 
            -
            Retrieve the settings from the eWallet API.
         | 
| 263 | 
            -
             | 
| 264 | 
            -
            ```
         | 
| 265 | 
            -
            settings = OmiseGO::Setting.all
         | 
| 266 | 
            -
            ```
         | 
| 313 | 
            +
            By default, points won't be burned and will be returned to the specified account's primary balance. If you wish to burn points, send them to a burn address. You may also send them to a secondary wallet if you prefer.
         | 
| 267 314 |  | 
| 268 315 | 
             
            Returns either:
         | 
| 269 | 
            -
            - An `OmiseGO:: | 
| 316 | 
            +
            - An `OmiseGO::List` of `OmiseGO::Wallet` instances (containing the 2 wallets involved in the transaction)
         | 
| 270 317 | 
             
            - An `OmiseGO::Error` instance
         | 
| 271 318 |  | 
| 272 | 
            -
             | 
| 273 319 | 
             
            ### Listing transactions
         | 
| 274 320 |  | 
| 275 321 | 
             
            #### Params
         | 
| @@ -281,9 +327,9 @@ Some parameters can be given to the two following methods to customize the retur | |
| 281 327 | 
             
            - `sort_by`: The sorting field. Available values: `id`, `status`, `from`, `to`, `created_at`, `updated_at`
         | 
| 282 328 | 
             
            - `sort_dir`: The sorting direction. Available values: `asc`, `desc`
         | 
| 283 329 | 
             
            - `search_term`: A term to search for in ALL of the searchable fields. Conflict with `search_terms`, only use one of them. See list of searchable fields below (same as `search_terms`).
         | 
| 284 | 
            -
            - `search_terms`: A hash of fields to search in: | 
| 330 | 
            +
            - `search_terms`: A hash of fields to search in:
         | 
| 285 331 |  | 
| 286 | 
            -
            ```
         | 
| 332 | 
            +
            ```ruby
         | 
| 287 333 | 
             
            {
         | 
| 288 334 | 
             
              search_terms: {
         | 
| 289 335 | 
             
                from: "address_1"
         | 
| @@ -297,7 +343,7 @@ Available values: `id`, `idempotency_token`, `status`, `from`, `to` | |
| 297 343 |  | 
| 298 344 | 
             
            Get the list of transactions from the eWallet API.
         | 
| 299 345 |  | 
| 300 | 
            -
            ```
         | 
| 346 | 
            +
            ```ruby
         | 
| 301 347 | 
             
            transaction = OmiseGO::Transaction.all
         | 
| 302 348 | 
             
            ```
         | 
| 303 349 |  | 
| @@ -307,29 +353,35 @@ Returns either: | |
| 307 353 |  | 
| 308 354 | 
             
            Parameters can be specified in the following way:
         | 
| 309 355 |  | 
| 310 | 
            -
            ```
         | 
| 311 | 
            -
            transaction = OmiseGO::Transaction.all( | 
| 312 | 
            -
               | 
| 313 | 
            -
             | 
| 314 | 
            -
             | 
| 315 | 
            -
             | 
| 316 | 
            -
             | 
| 317 | 
            -
                 | 
| 318 | 
            -
             | 
| 319 | 
            -
             | 
| 320 | 
            -
             | 
| 321 | 
            -
            } | 
| 356 | 
            +
            ```ruby
         | 
| 357 | 
            +
            transaction = OmiseGO::Transaction.all(
         | 
| 358 | 
            +
              params: {
         | 
| 359 | 
            +
                page: 1,
         | 
| 360 | 
            +
                per_page: 10,
         | 
| 361 | 
            +
                sort_by: 'created_at',
         | 
| 362 | 
            +
                sort_dir: 'desc',
         | 
| 363 | 
            +
                search_terms: {
         | 
| 364 | 
            +
                  from: "address_1",
         | 
| 365 | 
            +
                  to: "address_2",
         | 
| 366 | 
            +
                  status: "confirmed"
         | 
| 367 | 
            +
                }
         | 
| 368 | 
            +
              },
         | 
| 369 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 370 | 
            +
                          # defined in config
         | 
| 371 | 
            +
            )
         | 
| 322 372 | 
             
            ```
         | 
| 323 373 |  | 
| 324 374 | 
             
            #### All for user
         | 
| 325 375 |  | 
| 326 376 | 
             
            Get the list of transactions for a specific provider user ID from the eWallet API.
         | 
| 327 377 |  | 
| 328 | 
            -
            ```
         | 
| 378 | 
            +
            ```ruby
         | 
| 329 379 | 
             
            transaction = OmiseGO::Transaction.all(
         | 
| 330 380 | 
             
              params: {
         | 
| 331 | 
            -
                provider_user_id: " | 
| 332 | 
            -
              }
         | 
| 381 | 
            +
                provider_user_id: "provider_user_id01"
         | 
| 382 | 
            +
              },
         | 
| 383 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 384 | 
            +
                          # defined in config
         | 
| 333 385 | 
             
            )
         | 
| 334 386 | 
             
            ```
         | 
| 335 387 |  | 
| @@ -339,37 +391,46 @@ Returns either: | |
| 339 391 |  | 
| 340 392 | 
             
            Parameters can be specified in the following way:
         | 
| 341 393 |  | 
| 342 | 
            -
            ```
         | 
| 343 | 
            -
            transaction = OmiseGO::Transaction.all( | 
| 344 | 
            -
               | 
| 345 | 
            -
             | 
| 346 | 
            -
             | 
| 347 | 
            -
             | 
| 348 | 
            -
             | 
| 349 | 
            -
             | 
| 350 | 
            -
                 | 
| 351 | 
            -
             | 
| 352 | 
            -
             | 
| 353 | 
            -
            } | 
| 394 | 
            +
            ```ruby
         | 
| 395 | 
            +
            transaction = OmiseGO::Transaction.all(
         | 
| 396 | 
            +
              params: {
         | 
| 397 | 
            +
                provider_user_id: "provider_user_id01",
         | 
| 398 | 
            +
                page: 1,
         | 
| 399 | 
            +
                per_page: 10,
         | 
| 400 | 
            +
                sort_by: 'created_at',
         | 
| 401 | 
            +
                sort_dir: 'desc',
         | 
| 402 | 
            +
                search_terms: {
         | 
| 403 | 
            +
                  from: "address_1",
         | 
| 404 | 
            +
                  status: "confirmed"
         | 
| 405 | 
            +
                }
         | 
| 406 | 
            +
              },
         | 
| 407 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 408 | 
            +
                          # defined in config
         | 
| 409 | 
            +
            )
         | 
| 354 410 | 
             
            ```
         | 
| 355 411 |  | 
| 356 412 | 
             
            Since those transactions are already scoped down to the given user, it is NOT POSSIBLE to specify both `from` AND `to` in the `search_terms`. Doing so will result in the API ignoring both of those fields for the search.
         | 
| 357 413 |  | 
| 358 | 
            -
             | 
| 414 | 
            +
            ### Getting settings
         | 
| 359 415 |  | 
| 360 | 
            -
             | 
| 416 | 
            +
            #### All
         | 
| 361 417 |  | 
| 362 | 
            -
             | 
| 418 | 
            +
            Retrieve the settings from the eWallet API.
         | 
| 363 419 |  | 
| 364 | 
            -
             | 
| 365 | 
            -
             | 
| 366 | 
            -
             | 
| 420 | 
            +
            ```ruby
         | 
| 421 | 
            +
            settings = OmiseGO::Setting.all(
         | 
| 422 | 
            +
              client: nil # optional, defauls to nil and uses the client
         | 
| 423 | 
            +
                          # defined in config)
         | 
| 424 | 
            +
            )
         | 
| 425 | 
            +
            ```
         | 
| 367 426 |  | 
| 368 | 
            -
             | 
| 427 | 
            +
            Returns either:
         | 
| 428 | 
            +
            - An `OmiseGO::Setting` instance
         | 
| 429 | 
            +
            - An `OmiseGO::Error` instance
         | 
| 369 430 |  | 
| 370 | 
            -
             | 
| 371 | 
            -
             | 
| 372 | 
            -
             | 
| 431 | 
            +
            ## Models
         | 
| 432 | 
            +
             | 
| 433 | 
            +
            Here is the list of all the models available in the SDK with their attributes.
         | 
| 373 434 |  | 
| 374 435 | 
             
            ### `OmiseGO::AuthenticationToken`
         | 
| 375 436 |  | 
| @@ -390,12 +451,38 @@ Attributes: | |
| 390 451 | 
             
            - `data` (array of models)
         | 
| 391 452 | 
             
            - `pagination` (OmiseGO::Pagination)
         | 
| 392 453 |  | 
| 393 | 
            -
            ### `OmiseGO:: | 
| 454 | 
            +
            ### `OmiseGO::Token`
         | 
| 394 455 |  | 
| 395 456 | 
             
            Attributes:
         | 
| 457 | 
            +
            - `id` (string)
         | 
| 396 458 | 
             
            - `symbol` (string)
         | 
| 397 459 | 
             
            - `name` (string)
         | 
| 398 460 | 
             
            - `subunit_to_unit` (integer)
         | 
| 461 | 
            +
            - `metadata` (object)
         | 
| 462 | 
            +
            - `encrypted_metadata` (object)
         | 
| 463 | 
            +
             | 
| 464 | 
            +
            ### `OmiseGO::Wallet`
         | 
| 465 | 
            +
             | 
| 466 | 
            +
            Attributes:
         | 
| 467 | 
            +
            - `address` (string)
         | 
| 468 | 
            +
            - `balances` (array of OmiseGO::Wallet)
         | 
| 469 | 
            +
            - `socket_topic` (string, the channel for this wallet's events)
         | 
| 470 | 
            +
            - `name` (string, the name of the wallet)
         | 
| 471 | 
            +
            - `identifier` (string, the type of the wallet)
         | 
| 472 | 
            +
            - `metadata` (object)
         | 
| 473 | 
            +
            - `encrypted_metadata` (object)
         | 
| 474 | 
            +
            - `user_id` (string, user owning the wallet if applicable)
         | 
| 475 | 
            +
            - `user` (`OmiseGO::User`)
         | 
| 476 | 
            +
            - `account_id` (string, account owning the wallet if applicable)
         | 
| 477 | 
            +
            - `account` (`OmiseGO::Account`)
         | 
| 478 | 
            +
            - `created_at` (string)
         | 
| 479 | 
            +
            - `updated_at` (string)
         | 
| 480 | 
            +
             | 
| 481 | 
            +
            ### `OmiseGO::Balance`
         | 
| 482 | 
            +
             | 
| 483 | 
            +
            Attributes:
         | 
| 484 | 
            +
            - `amount` (integer)
         | 
| 485 | 
            +
            - `token` (`OmiseGO::Token`)
         | 
| 399 486 |  | 
| 400 487 | 
             
            ### `OmiseGO::User`
         | 
| 401 488 |  | 
| @@ -404,6 +491,22 @@ Attributes: | |
| 404 491 | 
             
            - `username` (string)
         | 
| 405 492 | 
             
            - `provider_user_id` (string)
         | 
| 406 493 | 
             
            - `metadata` (hash)
         | 
| 494 | 
            +
            - `metadata` (object)
         | 
| 495 | 
            +
            - `encrypted_metadata` (object)
         | 
| 496 | 
            +
             | 
| 497 | 
            +
            ### `OmiseGO::Account`
         | 
| 498 | 
            +
             | 
| 499 | 
            +
            Attributes:
         | 
| 500 | 
            +
            - `id` (string)
         | 
| 501 | 
            +
            - `parent_id` (string)
         | 
| 502 | 
            +
            - `name` (string)
         | 
| 503 | 
            +
            - `description` (string)
         | 
| 504 | 
            +
            - `master` (boolean)
         | 
| 505 | 
            +
            - `avatar` (hash)
         | 
| 506 | 
            +
            - `metadata` (object)
         | 
| 507 | 
            +
            - `encrypted_metadata` (object)
         | 
| 508 | 
            +
            - `created_at` (string)
         | 
| 509 | 
            +
            - `updated_at` (string)
         | 
| 407 510 |  | 
| 408 511 | 
             
            ### `OmiseGO::Exchange`
         | 
| 409 512 |  | 
| @@ -413,20 +516,22 @@ Attributes: | |
| 413 516 |  | 
| 414 517 | 
             
            - `address` (string)
         | 
| 415 518 | 
             
            - `amount` (integer)
         | 
| 416 | 
            -
            - ` | 
| 519 | 
            +
            - `token` (`OmiseGO::Token`)
         | 
| 417 520 |  | 
| 418 521 | 
             
            ### `OmiseGO::Transaction`
         | 
| 419 522 |  | 
| 420 523 | 
             
            - `id` (string)
         | 
| 421 524 | 
             
            - `idempotency_token` (string)
         | 
| 422 525 | 
             
            - `amount` (integer)
         | 
| 423 | 
            -
            - ` | 
| 526 | 
            +
            - `token` (`OmiseGO::Token`)
         | 
| 424 527 | 
             
            - `from` (`OmiseGO::TransactionSource`)
         | 
| 425 528 | 
             
            - `to` (`OmiseGO::TransactionSource`)
         | 
| 426 529 | 
             
            - `exchange` (`OmiseGO::Exchange`)
         | 
| 427 530 | 
             
            - `status` (string)
         | 
| 428 531 | 
             
            - `created_at` (string)
         | 
| 429 532 | 
             
            - `updated_at` (string)
         | 
| 533 | 
            +
            - `metadata` (object)
         | 
| 534 | 
            +
            - `encrypted_metadata` (object)
         | 
| 430 535 |  | 
| 431 536 | 
             
            ### `OmiseGO::Error`
         | 
| 432 537 |  | 
    
        data/lib/omisego/balance.rb
    CHANGED
    
    | @@ -1,39 +1,9 @@ | |
| 1 1 | 
             
            module OmiseGO
         | 
| 2 2 | 
             
              class Balance < Base
         | 
| 3 | 
            -
                attributes :amount, : | 
| 3 | 
            +
                attributes :amount, :token
         | 
| 4 4 |  | 
| 5 | 
            -
                 | 
| 6 | 
            -
                   | 
| 7 | 
            -
                    request(client).send('user.list_balances', provider_user_id: provider_user_id).data
         | 
| 8 | 
            -
                  end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                  def credit(provider_user_id:, token_id:, amount:, metadata: {}, idempotency_token:,
         | 
| 11 | 
            -
                             account_id: nil, burn_balance_identifier: nil, client: nil)
         | 
| 12 | 
            -
                    request(client)
         | 
| 13 | 
            -
                      .send('user.credit_balance', provider_user_id: provider_user_id,
         | 
| 14 | 
            -
                                                   token_id: token_id,
         | 
| 15 | 
            -
                                                   amount: amount,
         | 
| 16 | 
            -
                                                   metadata: metadata,
         | 
| 17 | 
            -
                                                   account_id: account_id,
         | 
| 18 | 
            -
                                                   burn_balance_identifier: burn_balance_identifier,
         | 
| 19 | 
            -
                                                   idempotency_token: idempotency_token).data
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                  def debit(provider_user_id:, token_id:, amount:, metadata: {}, idempotency_token:,
         | 
| 23 | 
            -
                            account_id: nil, burn_balance_identifier: nil, client: nil)
         | 
| 24 | 
            -
                    request(client)
         | 
| 25 | 
            -
                      .send('user.debit_balance', provider_user_id: provider_user_id,
         | 
| 26 | 
            -
                                                  token_id: token_id,
         | 
| 27 | 
            -
                                                  amount: amount,
         | 
| 28 | 
            -
                                                  metadata: metadata,
         | 
| 29 | 
            -
                                                  account_id: account_id,
         | 
| 30 | 
            -
                                                  burn_balance_identifier: burn_balance_identifier,
         | 
| 31 | 
            -
                                                  idempotency_token: idempotency_token).data
         | 
| 32 | 
            -
                  end
         | 
| 33 | 
            -
                end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                def minted_token
         | 
| 36 | 
            -
                  @_minted_token ||= MintedToken.new(@minted_token)
         | 
| 5 | 
            +
                def token
         | 
| 6 | 
            +
                  @_token ||= Token.new(@token)
         | 
| 37 7 | 
             
                end
         | 
| 38 8 | 
             
              end
         | 
| 39 9 | 
             
            end
         | 
| @@ -9,14 +9,15 @@ module OmiseGO | |
| 9 9 |  | 
| 10 10 | 
             
                OMISEGO_OPTIONS = {
         | 
| 11 11 | 
             
                  api_version: '1',
         | 
| 12 | 
            -
                  auth_scheme: ' | 
| 12 | 
            +
                  auth_scheme: 'OMGProvider',
         | 
| 13 | 
            +
                  api_prefix: '/admin/api',
         | 
| 13 14 | 
             
                  models: {
         | 
| 14 15 | 
             
                    user: OmiseGO::User,
         | 
| 15 16 | 
             
                    error: OmiseGO::Error,
         | 
| 16 17 | 
             
                    authentication_token: OmiseGO::AuthenticationToken,
         | 
| 17 | 
            -
                     | 
| 18 | 
            -
                    balance: OmiseGO:: | 
| 19 | 
            -
                     | 
| 18 | 
            +
                    wallet: OmiseGO::Wallet,
         | 
| 19 | 
            +
                    balance: OmiseGO::Wallet,
         | 
| 20 | 
            +
                    token: OmiseGO::Token,
         | 
| 20 21 | 
             
                    list: OmiseGO::List,
         | 
| 21 22 | 
             
                    setting: OmiseGO::Setting,
         | 
| 22 23 | 
             
                    transaction: OmiseGO::Transaction,
         | 
    
        data/lib/omisego/request.rb
    CHANGED
    
    | @@ -8,7 +8,6 @@ module OmiseGO | |
| 8 8 | 
             
                end
         | 
| 9 9 |  | 
| 10 10 | 
             
                def send(path, body, params: {}, conn: new_conn)
         | 
| 11 | 
            -
                  idempotency_token = body.delete(:idempotency_token)
         | 
| 12 11 | 
             
                  body = add_params(body, params)
         | 
| 13 12 |  | 
| 14 13 | 
             
                  response = conn.post do |req|
         | 
| @@ -16,7 +15,6 @@ module OmiseGO | |
| 16 15 | 
             
                    req.headers['Authorization'] = authorization
         | 
| 17 16 | 
             
                    req.headers['Accept'] = content_type
         | 
| 18 17 | 
             
                    req.headers['Content-Type'] = content_type
         | 
| 19 | 
            -
                    req.headers['Idempotency-Token'] = idempotency_token if idempotency_token
         | 
| 20 18 | 
             
                    req.body = body.to_json if body
         | 
| 21 19 | 
             
                    logger.log_request(req)
         | 
| 22 20 | 
             
                  end
         | 
| @@ -72,7 +70,7 @@ module OmiseGO | |
| 72 70 | 
             
                end
         | 
| 73 71 |  | 
| 74 72 | 
             
                def new_conn
         | 
| 75 | 
            -
                  @conn = Faraday.new(url: @config.base_url)
         | 
| 73 | 
            +
                  @conn = Faraday.new(url: "#{@config.base_url}#{@config.api_prefix}")
         | 
| 76 74 | 
             
                end
         | 
| 77 75 | 
             
              end
         | 
| 78 76 | 
             
            end
         | 
    
        data/lib/omisego/setting.rb
    CHANGED
    
    | @@ -1,16 +1,16 @@ | |
| 1 1 | 
             
            module OmiseGO
         | 
| 2 2 | 
             
              class Setting < Base
         | 
| 3 | 
            -
                attributes : | 
| 3 | 
            +
                attributes :tokens
         | 
| 4 4 |  | 
| 5 5 | 
             
                class << self
         | 
| 6 6 | 
             
                  def all(client: nil)
         | 
| 7 | 
            -
                    request(client).send(' | 
| 7 | 
            +
                    request(client).send('settings.all', {}).data
         | 
| 8 8 | 
             
                  end
         | 
| 9 9 | 
             
                end
         | 
| 10 10 |  | 
| 11 | 
            -
                def  | 
| 12 | 
            -
                  @ | 
| 13 | 
            -
                     | 
| 11 | 
            +
                def tokens
         | 
| 12 | 
            +
                  @_tokens ||= @tokens.map do |token|
         | 
| 13 | 
            +
                    Token.new(token)
         | 
| 14 14 | 
             
                  end
         | 
| 15 15 | 
             
                end
         | 
| 16 16 | 
             
              end
         | 
    
        data/lib/omisego/transaction.rb
    CHANGED
    
    | @@ -23,10 +23,21 @@ module OmiseGO | |
| 23 23 | 
             
                      address:          address
         | 
| 24 24 | 
             
                    }
         | 
| 25 25 |  | 
| 26 | 
            -
                    request(client).send('user. | 
| 26 | 
            +
                    request(client).send('user.get_transactions', body, params: params).data
         | 
| 27 27 | 
             
                  end
         | 
| 28 28 | 
             
                end
         | 
| 29 29 |  | 
| 30 | 
            +
                def create(from_address:, to_address:, token_id:, amount:, metadata: {}, encrypted_metadata: {})
         | 
| 31 | 
            +
                  request(client).send('transfer', {
         | 
| 32 | 
            +
                                         from_address: from_address,
         | 
| 33 | 
            +
                                         to_address: to_address,
         | 
| 34 | 
            +
                                         token_id: token_id,
         | 
| 35 | 
            +
                                         amount: amount,
         | 
| 36 | 
            +
                                         metadata:  metadata,
         | 
| 37 | 
            +
                                         encrypted_metadata:  encrypted_metadata
         | 
| 38 | 
            +
                                       }, params: params).data
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 30 41 | 
             
                def from
         | 
| 31 42 | 
             
                  @_from ||= TransactionSource.new(@from)
         | 
| 32 43 | 
             
                end
         | 
    
        data/lib/omisego/user.rb
    CHANGED
    
    | @@ -1,10 +1,10 @@ | |
| 1 1 | 
             
            module OmiseGO
         | 
| 2 2 | 
             
              class User < Base
         | 
| 3 | 
            -
                attributes :id, :username, :provider_user_id, :metadata
         | 
| 3 | 
            +
                attributes :id, :username, :provider_user_id, :metadata, :encrypted_metadata
         | 
| 4 4 |  | 
| 5 5 | 
             
                class << self
         | 
| 6 6 | 
             
                  def login(provider_user_id:, client: nil)
         | 
| 7 | 
            -
                    request(client).send('login', provider_user_id: provider_user_id).data
         | 
| 7 | 
            +
                    request(client).send('user.login', provider_user_id: provider_user_id).data
         | 
| 8 8 | 
             
                  end
         | 
| 9 9 |  | 
| 10 10 | 
             
                  def find(provider_user_id:, client: nil)
         | 
| @@ -12,29 +12,41 @@ module OmiseGO | |
| 12 12 | 
             
                    request(client).send('user.get', provider_user_id: provider_user_id).data
         | 
| 13 13 | 
             
                  end
         | 
| 14 14 |  | 
| 15 | 
            -
                  def create(provider_user_id:, username:, metadata: {}, | 
| 15 | 
            +
                  def create(provider_user_id:, username:, metadata: {},
         | 
| 16 | 
            +
                             encrypted_metadata: {}, client: nil)
         | 
| 16 17 | 
             
                    request(client).send('user.create', provider_user_id: provider_user_id,
         | 
| 17 18 | 
             
                                                        username: username,
         | 
| 18 | 
            -
                                                        metadata: metadata | 
| 19 | 
            +
                                                        metadata: metadata,
         | 
| 20 | 
            +
                                                        encrypted_metadata: encrypted_metadata).data
         | 
| 19 21 | 
             
                  end
         | 
| 20 22 |  | 
| 21 | 
            -
                  def update(provider_user_id:, username:, metadata: {}, | 
| 23 | 
            +
                  def update(provider_user_id:, username:, metadata: {},
         | 
| 24 | 
            +
                             encrypted_metadata: {}, client: nil)
         | 
| 22 25 | 
             
                    request(client).send('user.update', provider_user_id: provider_user_id,
         | 
| 23 26 | 
             
                                                        username: username,
         | 
| 24 | 
            -
                                                        metadata: metadata | 
| 27 | 
            +
                                                        metadata: metadata,
         | 
| 28 | 
            +
                                                        encrypted_metadata: encrypted_metadata).data
         | 
| 25 29 | 
             
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  def wallets(provider_user_id:, client: nil)
         | 
| 32 | 
            +
                    request(client).send('user.get_wallets', provider_user_id: provider_user_id).data
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                def login(client: nil)
         | 
| 37 | 
            +
                  self.class.login(provider_user_id, client: client)
         | 
| 26 38 | 
             
                end
         | 
| 27 39 |  | 
| 28 | 
            -
                def  | 
| 29 | 
            -
                   | 
| 40 | 
            +
                def update(username:, metadata: {}, encrypted_metadata: {}, client: nil)
         | 
| 41 | 
            +
                  self.class.update(provider_user_id: provider_user_id,
         | 
| 42 | 
            +
                                    username: username,
         | 
| 43 | 
            +
                                    metadata: metadata,
         | 
| 44 | 
            +
                                    encrypted_metadata: encrypted_metadata,
         | 
| 45 | 
            +
                                    client: client)
         | 
| 30 46 | 
             
                end
         | 
| 31 47 |  | 
| 32 | 
            -
                def  | 
| 33 | 
            -
                   | 
| 34 | 
            -
                           provider_user_id: provider_user_id,
         | 
| 35 | 
            -
                           username: username,
         | 
| 36 | 
            -
                           metadata: metadata
         | 
| 37 | 
            -
                         }, client)
         | 
| 48 | 
            +
                def wallets(client: nil)
         | 
| 49 | 
            +
                  self.class.wallets(provider_user_id: provider_user_id, client: client)
         | 
| 38 50 | 
             
                end
         | 
| 39 51 | 
             
              end
         | 
| 40 52 | 
             
            end
         | 
    
        data/lib/omisego/version.rb
    CHANGED
    
    
| @@ -0,0 +1,57 @@ | |
| 1 | 
            +
            module OmiseGO
         | 
| 2 | 
            +
              class Wallet < Base
         | 
| 3 | 
            +
                attributes :address, :balances, :socket_topic, :name, :identifier,
         | 
| 4 | 
            +
                           :metadata, :encrypted_metadata, :user_id, :user, :account_id,
         | 
| 5 | 
            +
                           :account, :created_at, :updated_at
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                class << self
         | 
| 8 | 
            +
                  def all(provider_user_id:, client: nil)
         | 
| 9 | 
            +
                    request(client).send('user.get_wallets', provider_user_id: provider_user_id).data
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def credit(provider_user_id:, token_id:, amount:, metadata: {}, user_address: nil,
         | 
| 13 | 
            +
                             encrypted_metadata: {}, idempotency_token:, account_id:, account_address: nil,
         | 
| 14 | 
            +
                             client: nil)
         | 
| 15 | 
            +
                    request(client)
         | 
| 16 | 
            +
                      .send('user.credit_wallet', provider_user_id: provider_user_id,
         | 
| 17 | 
            +
                                                  user_address: user_address,
         | 
| 18 | 
            +
                                                  token_id: token_id,
         | 
| 19 | 
            +
                                                  amount: amount,
         | 
| 20 | 
            +
                                                  metadata: metadata,
         | 
| 21 | 
            +
                                                  encrypted_metadata: encrypted_metadata,
         | 
| 22 | 
            +
                                                  account_id: account_id,
         | 
| 23 | 
            +
                                                  account_address: account_address,
         | 
| 24 | 
            +
                                                  idempotency_token: idempotency_token).data
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  def debit(provider_user_id:, user_address: nil, token_id:, amount:, metadata: {},
         | 
| 28 | 
            +
                            encrypted_metadata: {}, idempotency_token:, account_id:, account_address: nil,
         | 
| 29 | 
            +
                            client: nil)
         | 
| 30 | 
            +
                    request(client)
         | 
| 31 | 
            +
                      .send('user.debit_wallet', provider_user_id: provider_user_id,
         | 
| 32 | 
            +
                                                 user_address: user_address,
         | 
| 33 | 
            +
                                                 token_id: token_id,
         | 
| 34 | 
            +
                                                 amount: amount,
         | 
| 35 | 
            +
                                                 metadata: metadata,
         | 
| 36 | 
            +
                                                 encrypted_metadata: encrypted_metadata,
         | 
| 37 | 
            +
                                                 account_id: account_id,
         | 
| 38 | 
            +
                                                 account_address: account_address,
         | 
| 39 | 
            +
                                                 idempotency_token: idempotency_token).data
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                def user
         | 
| 44 | 
            +
                  @_user ||= User.new(@user)
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                def account
         | 
| 48 | 
            +
                  @_account ||= Account.new(@account)
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                def balances
         | 
| 52 | 
            +
                  @_balances ||= @balances.map do |balance|
         | 
| 53 | 
            +
                    Balance.new(balance)
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
            end
         | 
    
        data/lib/omisego.rb
    CHANGED
    
    | @@ -1,5 +1,6 @@ | |
| 1 1 | 
             
            require 'faraday'
         | 
| 2 2 | 
             
            require 'json'
         | 
| 3 | 
            +
            require 'base64'
         | 
| 3 4 |  | 
| 4 5 | 
             
            require 'omisego/invalid_configuration'
         | 
| 5 6 | 
             
            require 'omisego/error_handler'
         | 
| @@ -13,10 +14,10 @@ require 'omisego/base' | |
| 13 14 | 
             
            require 'omisego/error'
         | 
| 14 15 | 
             
            require 'omisego/pagination'
         | 
| 15 16 | 
             
            require 'omisego/list'
         | 
| 16 | 
            -
            require 'omisego/ | 
| 17 | 
            +
            require 'omisego/token'
         | 
| 17 18 | 
             
            require 'omisego/setting'
         | 
| 18 19 | 
             
            require 'omisego/balance'
         | 
| 19 | 
            -
            require 'omisego/ | 
| 20 | 
            +
            require 'omisego/wallet'
         | 
| 20 21 | 
             
            require 'omisego/user'
         | 
| 21 22 | 
             
            require 'omisego/authentication_token'
         | 
| 22 23 | 
             
            require 'omisego/exchange'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: omisego
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.10.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Thibault
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018- | 
| 11 | 
            +
            date: 2018-06-19 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: faraday
         | 
| @@ -160,7 +160,7 @@ files: | |
| 160 160 | 
             
            - bin/setup
         | 
| 161 161 | 
             
            - changelog
         | 
| 162 162 | 
             
            - lib/omisego.rb
         | 
| 163 | 
            -
            - lib/omisego/ | 
| 163 | 
            +
            - lib/omisego/account.rb
         | 
| 164 164 | 
             
            - lib/omisego/authentication_token.rb
         | 
| 165 165 | 
             
            - lib/omisego/balance.rb
         | 
| 166 166 | 
             
            - lib/omisego/base.rb
         | 
| @@ -172,15 +172,16 @@ files: | |
| 172 172 | 
             
            - lib/omisego/http_logger.rb
         | 
| 173 173 | 
             
            - lib/omisego/invalid_configuration.rb
         | 
| 174 174 | 
             
            - lib/omisego/list.rb
         | 
| 175 | 
            -
            - lib/omisego/minted_token.rb
         | 
| 176 175 | 
             
            - lib/omisego/pagination.rb
         | 
| 177 176 | 
             
            - lib/omisego/request.rb
         | 
| 178 177 | 
             
            - lib/omisego/response.rb
         | 
| 179 178 | 
             
            - lib/omisego/setting.rb
         | 
| 179 | 
            +
            - lib/omisego/token.rb
         | 
| 180 180 | 
             
            - lib/omisego/transaction.rb
         | 
| 181 181 | 
             
            - lib/omisego/transaction_source.rb
         | 
| 182 182 | 
             
            - lib/omisego/user.rb
         | 
| 183 183 | 
             
            - lib/omisego/version.rb
         | 
| 184 | 
            +
            - lib/omisego/wallet.rb
         | 
| 184 185 | 
             
            - omisego.gemspec
         | 
| 185 186 | 
             
            homepage: https://omg.omise.co/
         | 
| 186 187 | 
             
            licenses:
         |