<commit_before># User

## Create a user

```ruby
# Make sure we are in Sandbox
SynapsePay.api_base = SynapsePay.api_sandbox

SynapsePay.client_id = "client-id"
SynapsePay.client_secret = "client-secret"

# This creates an oauth client for the newly created user.
client = SynapsePay::User.create({
  :email => "<EMAIL>",
  :fullname => "<NAME>",
  :ip_address => "1192.168.3.11",
  :phonenumber => "123456789"
})
```


## Login as a user

```ruby
# Make sure we are in Sandbox
SynapsePay.api_base = SynapsePay.api_sandbox

SynapsePay.client_id = "client-id"
SynapsePay.client_secret = "client-secret"

# Returns an oauth client for this user
client = SynapsePay::User.login("username", "password")
```


## Refresh access

```ruby
# Make sure we are in Sandbox
SynapsePay.api_base = SynapsePay.api_sandbox

SynapsePay.client_id = "client-id"
SynapsePay.client_secret = "client-secret"

client = SynapsePay::Client.refresh_access("refresh-token")

# Alternatively, if you already have a client:
client.refresh_access<commit_msg>Adding an example with force_create = "no"<commit_after># User

## Create a user

```ruby
# Make sure we are in Sandbox
SynapsePay.api_base = SynapsePay.api_sandbox

SynapsePay.client_id = "client-id"
SynapsePay.client_secret = "client-secret"

# This creates an oauth client for the newly created user.
client = SynapsePay::User.create({
  :email => "<EMAIL>",
  :fullname => "<NAME>",
  :ip_address => "1192.168.3.11",
  :phonenumber => "123456789"
})
```

## Create a user with force_create = "no"

This will return an existing user instead of throwing an error if one exists.

```ruby
# Make sure we are in Sandbox
SynapsePay.api_base = SynapsePay.api_sandbox

SynapsePay.client_id = "client-id"
SynapsePay.client_secret = "client-secret"

# This creates an oauth client for the newly created user.
client = SynapsePay::User.create({
  :email => "<EMAIL>",
  :fullname => "<NAME>",
  :ip_address => "1192.168.3.11",
  :phonenumber => "123456789",
  :force_create => "no"
})
```


## Login as a user

```ruby
# Make sure we are in Sandbox
SynapsePay.api_base = SynapsePay.api_sandbox

SynapsePay.client_id = "client-id"
SynapsePay.client_secret = "client-secret"

# Returns an oauth client for this user
client = SynapsePay::User.login("username", "password")
```


## Refresh access

```ruby
# Make sure we are in Sandbox
SynapsePay.api_base = SynapsePay.api_sandbox

SynapsePay.client_id = "client-id"
SynapsePay.client_secret = "client-secret"

client = SynapsePay::Client.refresh_access("refresh-token")

# Alternatively, if you already have a client:
client.refresh_access
{'fraction_non_alphanumeric': 0.13003452243958574, 'fraction_numerical': 0.02186421173762946, 'mean_word_length': 4.954337899543379, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3245162', 'n_tokens_mistral': 971, 'n_tokens_neox': 880, 'n_words': 239}